Every time I make a new conditional formatting rule it changes and breaks. This happens before I click apply, but after I have created the rule. If I apply the rule it, naturally, applies completely incorrectly, but I don't have any idea what the formula is checking. If I then edit the text of the formula after applying it, it will then work and stay the way I have written it.
It seems to be just adding a long string of numbers at the end of my formula location.
In the images below I am adding a new formula:
=$J1="N"
but after hitting ok it changes to this:
=$J1048564="N"
Not sure what I am doing wrong here, so any help would be greatly appreciated!
The row number does not have a $ sign, so it is relative. It is relative to the cell that was the active cell when the format was defined.
If you apply a format to A1:A1000, but the currently active cell is in row 500, then a relative reference to $A1 in the formula will be interpreted as "The cell 499 rows above the current cell". When that format is applied, then Excel will try to find that position for each row. In row 1, it cannot go 499 cells above, so it starts over at the last cell of the sheet and goes 499 up from there.
Of course you don't want all that.
So, when you define a conditional format that applies to many rows, make sure that the currently active cell is at the top left of the selected range, so any relative cell references will be applied relative to that cell position.
You may want to remove your CF completely and start over.
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.
I'm currently working in excel, and I'm trying to figure out a way to find if multiple cells contain the string value of another cell, and if it does highlight the cell where the row and column meet up. I created an example of what I want, only it will be on a much larger scale.
I've tried using: =ISNUMBER(SEARCH(substring,text)) but I'm not quite sure how to use it the way I want to.
Any help will be appreciated!
Your approach is correct, we can use the fact that conditional formatting is applied like dragging a formula, adapting relative references.
Create a conditional formatting formula rule:
=ISNUMBER(SEARCH(B$1,$A2))
Applied to B2:D7
Your formula will work nicely; what you'll want to do is put that formula into all the cells you want to highlight, so you get FALSE and TRUE in every cell.
You'll then use two Conditional Formatting rules. The first will look for Cell Value = TRUE, and will set cell background and font colour to yellow. The second will look for Cell Value = FALSE, and will set cell background to No Colour and Font to White.
This will reproduce the result you're looking for.
Edited to add:
It is possible to do this using just Conditional Formatting too, but it's a little more fiddly. If you want to try it, you can do this:
Highlight your range, and take note of which cell is Active - that's the cell within your highlighted range that is still white. It's also the one whose address is shown in the Name box in the upper left. For the sake of this answer, we'll assume that's B2
Create a new Conditional Formatting rule. Choose "Use a formula to determine which cells to format".
Use the formula =ISNUMBER(SEARCH(B$1,$A2). Set the format to colour just the cell background.
Note where the $ appears in the formula above - you want to leave the row number anchored in the first part, and the column letter anchored in the second part.
This takes advantage of the fact that Conditional Formatting is able to use absolute, relative, and mixed references to find which cells to format. It's also a tidier solution, but it can be harder to maintain if the sheet is ever repurposed or modified.
I regularly encounter an issue on Excel 2010 when I create a new rule using a formula. The issue is reproducible on several of my computers. I select several cells (for instance A4:B143) and then create a new rule using one of the following formulas:
=$A4="issue"
=($A4="issue")
then press Enter. The goal is, of course, to see all the rows of which the first cell's value is "issue". But this does not work and when I go to "manage rules", I see that Excel has the following formula:
=$A1048441="issue"
This is the formula that I want but not with the number that I entered. If I manually replace this new formula that comes out of nowhere (in my eyes) with my old formula, everything works correctly and the formula stays =$A4="issue".
Does anyone know what might cause this issue?
Please try selecting from top left to bottom right rather than vice versa.
Without the anchor ($) for rows (has to be left off for the one formula rule to apply throughout the range) the row references are relative - but relative to the active cell rather than to the top row.
The active cell when selecting a range is the one that starts the range selection. So a range that is selected from B143 to A4 has B143 as the active cell (not A4). Relative to that Row4 is 139 rows earlier. For CF, 139 rows earlier than A4 is Row1048441 in Excel 2010 (the rows 'wrap' - the last row, Row1048576, is in effect immediately before Row1, so Row1048441 + 136 gets back to Row1 and plus another 3 from there to get to Row4. 136+3 is the 139 difference).
I was able to do apply it in the following manner:
When I entered the formula, I did not put an = sign before. I just put $a6=issue
Rules:
Data:
I currently have a worksheet where column C changes to red if it is due in the next seven days. I would like to have the row change to a different format if I enter ANY date in column E. I have tried a bunch of different ways but I can only get the E cells to change or the entire worksheet and it seems to ignore the E entry.
Here is a link to the file:
http://mpereaseportfolio.weebly.com/uploads/2/5/6/2/25627115/summer_assingment_schedule.xlsx
Try this:
Select the whole range of data except headers, i.e. A2:H193
Now apply a new condition in conditional formatting using the formula
=$E2<>""
Select required format
Make sure that condition is at the top and tick "Stop if TRUE" so that other conditions are not applied
Note that you need exactly that formula including the $
Note also that the formula always refers to the first row of data but will work for the whole range
Please try a formula rule such as:
=(IFERROR(FIND(" AM",$E2),FIND(" PM",$E2))>0)
with applies to =$A$2:$H$200 or similar
What I'm doing is a simple map on one tab of an office space that has all the cubicals laid out. On this map, I have conditional formatting checking another table of listen computers for the last time they were updated/maintained. It works as it stands, but we are moving into a new building and the map (which is already done) has WAY more cubes than last time. So I'm trying to figure out a more efficient way to do this task.
Here is the code:
=AND(VLOOKUP("CCA C1",LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
So as it sits, it works fine. But what I'm trying to do is change the "CCA C1" to simply read the contents of the cell it's formatting so I can just format an entire range of cells rather than doing it cell by cell. The "CCA C1" is in the location of the second sheet (it's a named range). So this checks that entire range for "CCA C1" and checks if the date a couple columns over in that row is within 80 days, if it's not it highlights the cell in the map in red reminding us we need to check the computer. But what I would like to do is simply put "CCA C1" in the cell in the map (which is already is labeled), and have this check for the value of the cell it's formatting and look for that value the same way it's looking now. Just without me having to put "CCA C1" in the formula, I'd like to say something like this:
=AND(VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<>"",VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<TODAY()-80)
Make sense? Anyone know of a way to do this? Otherwise I have to conditionally format each individual cell with the value manually rather than just format all the cells with the same formatting and have the formula check the contents of the cell for what to look for in the location range of the other sheet.
And to clarify, I know that I can put in the actual cell, such as E3, but then I still have to manually change the formula for each cell which defeats the purpose. I want to just say current cell or something like that. I have 3 conditional formats for each cell, I have around 100 cells to be formatted, so rather than having 300 formats I have to put in, I'd love to just do 3. Not sure if this is possible, that's why I'm asking :)
Just replace "CCA C1" with the address of the first cell in the range of cells with the conditional formatting. Assuming your conditional formatting starts in B2:
=AND(VLOOKUP(B2,LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
EDIT: As I commented, I'm not sure I understand the issue, but if I do, you need to enter the range of cells with CF in the applies to range of the CF dialog, rather than copying and using Paste Special:
Note that this works with the merged cells.
You will need to adjust the applies to range as you add more computers, etc., but the same formula will work.