Can Excel Conditional Formatting use UDFs in the condition? - excel

I have a cell in Excel that I want to format differently based on a user defined formula (UDF) - my formula tests whether there is a formula in the cell...
I am trying to use conditional formatting with my UDF to format the cell - but it does not seem to be working.
My condition is this:
="isManualPrice(R22C12)"
I tried without the quotes, but get the error
You cannot use references to other
worksheets or workbooks for
Conditional Formatting criteria
Perhaps the issue relates to my UDF being defined in a separate macro workbook and not my main workbook...
I see its mentioned in this blog entry from 2005, but only in passing...
Thanks in advance.
Chris

Yes, it can.
Your problem is simply that you've got quotes in there. You need to choose "Formula Is" from the drop-down, and then your formula should be
=isManualPrice(R22C12)
...with no quotes.
(I'm more used to A1 notation rather than R1C1 notation but I assume that'll work just as well).

Related

Evaluate an expression as a formula in Excel

I have created an expression using "&" to concatenate different cells, I created this:
=INDEX((Data_sheet!A1:M20440;Data_sheet!A20441:M40880;Data_sheet!A40881:M61320);20;5;D2)
Now, I have the expression that is a formula, but it is not evaluated as a formula when I paste it, I can see the whole expression in the cell, but I want to get is the value that is behind evaluating that formula. I want to know how to make it to evaluate as a formula (because I will have thousands of this expressions)
My guess is that you would have created the INDEX formula in excel using multiple other formulas.
Once you have created the formulas, copy all the formulas and paste it in a txt file. Then, copy all the formulas from txt file and paste it again in the excel where you want the formulas to perform. This is the simplest way of doing this without creating any macros or additional formulas
See this question for solutions:
How to turn a string formula into a "real" formula
In particular, also note the answer about Excel's hidden EVALUATE function, that can only be accessed after defining a name to use it.
https://www.vertex42.com/ExcelArticles/evaluate-function.html

How to translate this formula translated into VBA?

I have this formula below that I am attempting to use to perform different calculations depending on the data in the referenced cells. The formula works, but I need to have more flexibility on the data found.
=IF(AND(U1="APO 300%",$E2="P+"),P2-(SUMIF($F$2:$F$74,300%,H$2:H$74)*M2)-(SUMIF($F$2:$F$74,150%,H$2:H$74)*M2),IF(AND(U1="APO 300%",$E2="P"),H2,""))
Is there a code that can duplicate this?
Worksheets have an Evaluate method which can be used to do what you want:
shtObject.Evaluate("A1+B1") '<<< substitute in your formula

Excel conditional formatting based on cell content

I am trying to write a conditional formatting formula for the rule "if the first cell of this row is NOT empty AND the current cell IS empty".
Basically I am trying to bring attention when a user has forgotten to enter a value in a cell.
The formula I came up with was:
="NOT(isblank($A1)) AND isblank(A1)"
Please provide an explanation why my formula is wrong, not just the correct formula =)
The logical "AND" is not an operator in Excel, it is just another function. Excel doesn't know how to evaluate =FUNCA() AND FUNCB(). Instead, wrap the two functions inside the AND function:
=AND(NOT(ISBLANK($A8)), ISBLANK(M8))

Conditional Formatting for a cell containing a particular equation

I tried using steps identified here but realized that it refers to cells that have any formula in them. I would like to format based on one particular formula.
Is it possible to use conditional formatting to refer to a cell that only has a particular equation, for example an "IF" statement in the cell?
You don't mention what the formula is but do mention an IF statement so suggest (though clearly not Conditional Formatting in the conventional sense), HOME, Editing - Find & Select, Find what:
=*IF(*
Find All, Ctrl+A, and formatting of your choice.

excel can VBA UDF output formatted text?

Is there a way to return a string from an UDF formatted? For example I would like first two words to be bold, the rest not.
Functions are not allowed to alter the formatting of the worksheet. That being said, Sub() can and you can easily write a Sub routine that does this - it just means you'll have to run the macro (like using F8) instead of entering it as a formula inside a cell.
Sorry, but you can't apply rich text formatting to the result of a formula.

Resources