I'm currently using "Format only cells that contain" rule to highlight websites with suspect TLDs, in Excel 2010 and that works; but I have to make a new rule for every match value. Cumbersome to maintain.
Sample Data
Websites B:B
rcdesign.ru
htw.pl
opx.pl
TLDs A:A
.pl
.ru
I have another workbook that CF based on cell value matches in another column, but it's formula uses exact matches.
=ISNUMBER(MATCH(B1,TLDs!C:C,0))
Because my new sheet has partial matches, the suggested formula on another forum switches the array, and the look up value, but their formula spits an error.
Suggested Formula from another forum (gives error)
=INDEX(A1:A4, MATCH(TRUE, ISNUMBER(FIND(A1:A4, B1)), 0) )
My edit for Conditional Formatting.
=ISNUMBER(FIND(A1:A4, B1))
(I want to use this formula to activate conditional formatting, so INDEX() isn't needed.)
If functional, the cells in B:B column will format conditionally. What did I do wrong? (I did use Ctrl+Shift+Enter to make it an array formula in my test cell C1)
I'm sorry my original question was so vaguely worded as #BruceWayne pointed out.
I found an incredibly convoluted solution.
=NOT(ISNA(INDEX(A$1:A$8,MATCH(TRUE,ISNUMBER(FIND(A$1:A$8,B1)),0))))
This formula works as criteria for conditional formatting.
The only thing I haven't figured out yet is how to make A$1:A$8 into A:A; because any empty cells in the array cause false positives.
Related
I'm trying to format a row based off a cell within it.
My table runs from A6 to K207 and I want to highlight the row in bold if the cell in B6 starts with SA.
I tested my formula
=IF(LEFT(TRIM(B26),2)="SA","YES","NO")
in another cell and that works ok - but I can't get the formatting to work for some reason...
I removed the yes/no and placed into a conditional formatting rule applying to my whole table and it doesn't work. Even if I apply it to just a row it doesn't work.
Am I using if statements within conditional formatting right? I've looked on Google and here and have found similar issues but not the same one, they've all used set values/ranges but not a 'starts with' condition.
The conditional formatting is an IF statement by default, and formats depending on whether the formula is TRUE or FALSE therefore an additional IF statement is not needed:
=LEFT($A6,2)="SA"
This will do the trick, apply this to the entire range as needed.
It will test whether all cells in column a start with "SA" and highlight that cell. If it is applied to a range including more columns, the $ sign fixes the column as A so tests that cell and highlights every cell based on that, effectively highlighting the entire row.
You can also use an OR statement to pass multiple arguments like so:
=OR(LEFT($A6,2)="SA",LEFT($A6,2)="BO")
Welcome to SO. When doing conditional formating (CF) in a formula, you need to apply references.
Switch between relative, absolute, and mixed references
Right now your formula is =IF(LEFT(TRIM(B26),2)="SA","YES","NO"). You are using relative references, so the CF rule will check according to their position. In A6 it will check the value of A6, and I guess you would like the rule to check the value always in column B.
So the first fix you need in yor formula will be (it needs more, hold on)
=IF(LEFT(TRIM($B26),2)="SA","YES","NO")
Now, it will check always the value in column B. But we need to fix something else. To make the CF based on a formula, you need to formulate something that returns a boolean value, True or False. Your values Yes or NO are strings (text), not boolean, so they don't work.
So try this formula and let's see if it works:
=IF(LEFT(TRIM($B26),2)="SA",TRUE,FALSE)
An IF Functions allows you to make a question where the answer must be yes/no (true/false) and, depending of the answer, Excel will do an option or another.
With CF rule based on a formula, you just need the question itself, you don't need to choose an option. So the short version of this formula, as #Plutian states in his answer, is just doing:
=LEFT(TRIM($B26),2)="SA"
Try to adapt this to your needs.
How to highlight cells that have a specific formula.
E.g cells that have a formula of "vlookup".
I knew search/replace can always look into formulas. But how to look into formula for conditional formatting?
Using conditional formatting, based on this kind of formula:
=FIND("VLOOKUP";FORMULATEXT(...))
Keep in mind that find() seems to be case sensitive.
More elaborated: imagine you have a formula with VLOOKUP() in cell B2. On the cell you want to highlight, you can use conditional formatting (Home ribbon, Conditional formatting, Highlighting cell rules, More rules, "Use a formula"), and as a formula, you use the following:
=IFERROR(FIND("VLOOKUP";FORMULATEXT(B2));FALSE)>0
Explanation:
FIND() searches for the word "VLOOKUP" in cell B2 (mind the uppercase).
FORMULATEXT() converts the formula in normal text, and can be used as input for FIND().
In case the word "VLOOKUP" is not found, an error is shown.
The IFERROR() function deals with the error, showing FALSE as a result.
The "greater than" check makes sure that the formula results in TRUE, enabling the formula for the conditional formatting.
In the below example we use:
"=VLOOKUP" in column B to get the value of Column A from the range in H3:I3.
"=FORMULATEXT" in Column C to get the value of Column B.
"=IF((IFERROR(FIND("VLOOKUP",C2,1),0))>0,"Appears","Not Appears")" in Column E to check if words "VLOOKUP" appears in Column C.
Images:
Edited from #Dominique suggestions and it seems working.
'=IF(FIND("VLOOKUP",FORMULATEXT(A1)),TRUE)'
I have a question with regards to conditional formatting which I simply can't seem to solve.
The aim is to format the background color for the left-most cells that are blank up until a cell contains a value - and after this there should be no more formatting in this row. You can see an image of the result I'm hoping for beneath:
So far I've managed to create the conditional formatting of the blank rows, but sadly haven't managed to create the "single-cell" formatting (in yellow) conditional of the sum of all the first cells being = 0.
I've created a formula which actually succeeds in calculating the sum of the previous cells, but this formula includes INDIRECT() which it seems that conditional formatting doesn't allow. At least I'm getting an error starting with the follow (translating the error from Danish to English might not be intuitive):
You cannot use reference operators such as.....
The formula I'm trying is the following:
=AND(SUM(A2:INDIRECT(IF(COLUMN(A2)>=27;CHAR((64-26)+COLUMN(A2))&CHAR((64-26)+COLUMN(A2))&ROW(A2);CHAR((64)+COLUMN(A2))&ROW(A2))))>0;$K2>0)
Where $K2 is the sum of the row.
Is there a way to SUM a range of cells by doing something similar to this:
=SUM(B2:CHAR((64)+COLUMN())&ROW();"")) to dynamically SUM the range from B2 to the current cell? The problem in this case is whether the part CHAR((64)+COLUMN())&ROW();"") can be converted into a legible cell such as B4 to make it work inside the =SUM() formula?
Sadly the =ADDRESS() formula cannot be used (as far as I know) as this will trigger the same error in conditional formatting as well.
For now I would like this to work with the regular Excel conditional formatting, but if anyone have a simple VBA this would also have interest - however, I would by far prefer the regular solution.
The question:
Is there a way to create a formula that doesn't trigger this error - maybe by refrasing the formula or doing something completely else?
It seems to me that this could be handled with a much simpler CFR formula like,
=and(not(sum($a2:a2)), $k2)
Am I missing something?
What I am trying to achieve is if a cell in column AB equals "Yes" and a cell in column AC is blank, then a certain range of cells will be formatted. Currently the rule is not formatting cells that it should. I am basing this code on another formatting rule I am using that works properly, but does not use AND().
=AND(INDIRECT("ab"&ROW())="Yes", INDIRECT("ac"&ROW())="")
I am sure this is an obvious syntax mistake, but I am still very new to Excel and can't figure out why this isn't working.
Try This:
=AND($AB1="YES",$AC1="")
Use the format painter to drag the formula around.
As Jeeped said, change the 1 in $AB1 and $AC1 to your first row.
I am formatting cell D25 using the following conditional formatting formula:
=(VLOOKUP($C25;$C$6:$L$18;2)+D25)>32
When applying the formula to the adjacent column I get formula updates to
=(VLOOKUP($C25;$C$6:$L$18;**2**)+E25)>32
Using the Copy and Paste Format function works mostly i.e. references in the formula are updated as I would expect.
The only (essential) thing that doesn't update is the INDEX value in the VLOOKUP formula. I would expect this value to increase by 1 when copying the format to the next column - it doesn't.
Is there any way to go around this issue with VLOOKUP? Is there a better suited formula to achieve the same result?
Any help will be greatly appreciated!!
This value does not increase automatically, and it is good. This formula was designed to be used on Tables, so consistency is a point here.
For conditional formatting, you may want to use $ to lock some references. For example, let we have the simple sheet as below:
First, select the range in the CORRECT order. This is important. the first cell you select will be reference for offsets of the conditional formatting. For this example, let's do it like this:
Now, let's go for the conditional formatting itself! Conditional Formatting > New Rule... > Use a formula to determine which cells to format. And let's put this formula:
=if($A1<=2;TRUE;FALSE)
Click OK and...
There we go! We just formatted the lines in witch An is equal or less than 2! Please note that we only had to lock the COLUMN of the reference. So, logically, to format the columns we would have locked the ROW.
Hope it helps!
EDIT:
If you REALLY want to use VLOOKUP, which I DO NOT recommend, you can just use the formula:
=(VLOOKUP($C25;$C$6:D$18;COLUMNS($C$6:D$18))+E25)>32
To change the index dinamically.