I am trying to format a row to change color based on the value of the cells at the end of the row. For whatever reason, Excel is forcing the Applies to to contain additional $ and the cells are not highlighting in any logical way.
Here is what I am trying to do:
If Column I = Yes & Column J = Yes -> Row "Fill Color" is Green
If Column I = No & Column J = Yes -> Row "Fill Color" is Orange
If Column I = No & Column J = No -> Row "Fill Color" is Red
The formulas I am using are as follows:
=OR(I$3<>"Yes",J$3<>"Yes") Format: Fill Red Applies to =A$3:D$3
=OR(I$3="No",J$3<>"Yes") Format: Fill Orange Applies to =A$3:D$3
=OR(I$3="Yes",J$3="Yes") Format: Fill Green Applies to =A$3:D$3
Excel keeps changing the Applies to to be =A$3:$D$3 and even though I keeping changing it to =A$:D$3 I can't seem to find why.
Currently, here is the behavior I am seeing:
Column A is Orange and columns B-D are staying Red when I & J are Yes
Columns A-D are Red when and J is No regardless of what column I is
Columns A-D do not turn Green in with any combination
Am I missing something really simple? I can't seem to figure out why it would work this way.
Two things...
$ Sign
I believe the $ behavior you are seeing is normal... The formulas can be relative or absolute cells, but the ranges to which the rules apply should not be and would not have any reason to be.
Logic
I believe your logic problem will be embarrassingly obvious once you step back for a moment and look at your formulas. In your text version of your logic you describe your logical condition as AND(). That is, if I is <> "yes" AND J is <> "yes". But take a look at your formulas.
You didn't enter:
=AND(I$3<>"Yes",J$3<>"Yes")
but rather you entered:
=OR(I$3<>"Yes",J$3<>"Yes")
Change OR to AND and I suspect you are back in business.
Related
I don’t want to use conditional formatting because I need a different value as the text in the cell (not what the color values apply to).
Column E is status (at risk/on track/needs improvement)
Column I is trend, displayed as arrows (Unicode text)
Column J is blank
I would like the color of the corresponding cells to be based on Column E text “Needs Improvement” in red, “At Risk” in yellow, and “On Track” in green.
So - in J2 through J13, I need the color only from the E2:E13 status and the trend arrows from I2:I13
I know this has been asked before in one way or another, but I can’t figure out the conditional formatting in VBA for some reason. Im sorry
Conditional formatting doesn’t work, I was trying to pull conditional colors from column E, but the only code I could get to work couldn’t integrate conditional formatting colors (it had to be true cell colors)
Below are the 4 sets of conditional formatting I used to accomplish the below example. I did not know what your trend data looks like so you'll need to adjust that to fit. To note, the formula in column J is ["=I" & row], so it's pulling over the same values. Those are hidden with the icon formatting. ::
Where RG = range("J2:J18")
Colour:="Red" while [=$E2="At Risk"]
Colour:="Yellow" while [=$E2="Needs Improvement"]
Colour:="Green" while [=$E2="On Track"]
Shape:="Icon Set" [checkmark] Show Icon Only
Example of formatting:
Example of result:
Let me know if any of that doesn't make sense.
I've been having issues conditionally formatting a sheet 2 (Shipping Request List) that is mirroring select columns of sheet 1 (Master List).
-Starting in sheet 2 (Shipping Request List), column B, cell B2, has ='Master List'!D2 (from sheet 1) and continues down for hundreds of rows.
-The data in this field is mirroring cell 'Master List'!D2 (sheet 1) which could either be "Open" (or a number of other items based off a drop down list... no formulas). I'm only interested in what happens when the cell says, "Open".
-Cell D2 in sheet 1 has the following conditional formats based on D2 saying "Open" and a date in cell V2 in the Master List sheet.
=AND($V2<TODAY(),$D2="open") [turns purple]
=AND($V2-TODAY()>=0, $V2-TODAY()<=2,$D2="open") [turns red]
=AND($V2-TODAY()>=3, $V2-TODAY()<=4,$D2="open") [turns orange]
=AND($V2-TODAY()>=5, $V2-TODAY()<=7,$D2="open") [turns yellow]
When I try conditional formatting based on the values in sheet 2, i.e. by the value "Open" mirrored from sheet 1, the colors are not correct.
I tried various approaches.
Approach 1:
Change the conditional format equations in sheet 2 to reference the cell in sheet 1 instead of directly referencing the cells in sheet 2.
Approach 2:
Try using INDIRECT in the conditional format equations in sheet 2...but I'm not sure I did this correctly.
Approach 3:
Use a VBA code to create a UDF on sheet 1 to extract the color code of column D into an adjacent column (C), then filter by that number for the codes that represent purple, red, orange, and yellow.
(I am not at all good with VBA, but I can copy and paste a module and follow instructions.)
Function FindColor(n As Range) As Integer
FindColor = n.Interior.ColorIndex
End Function
In column C, C2 had =findcolor(D2) and then that got pulled down. This approach gave me numbers, but it gave me the same number for purple, blank, etc... extremely inconsistent.
Approach 4:
In new column C, add a formula to make the words either "purple", "red", "orange", or "yellow" appear based on the conditions mentioned in the conditional formatting formulas. I got only so far as the formula started getting a little too complicated for me to get through it. Only got this far (didn't even add orange and yellow yet) but the formula below is not returning "red" when the conditions call for it:
=IF(AND($V662<TODAY(),$D662="open"),"purple",IF(AND($V662-TODAY()>=0,$V662-TODAY()<=2,$V662="open"),"red",""))
I think I was getting close on the last approach, but I realize it's a lot of formula and will be added to 700+ rows, which will continue to grow.
As a slightly different approach: you could use a UDF to return the "color" for each row, and then run your conditional formatting rules based on the return values.
Put this in a regular module:
Function Classify(theDate, theStatus) As String
If theStatus = "open" Then 'check status
'If theStatus = "open" Or theStatus = "issue" Then
If Len(theDate) > 0 Then 'has a date?
Select Case theDate - Date
Case Is < 0: Classify = "purple"
Case Is >= 5: Classify = "yellow"
Case Is >= 3: Classify = "orange"
Case Is >= 0: Classify = "red"
End Select
End If
End If
End Function
In your worksheet you'd use (eg)
=Classify($V662, $D662)
I have made an Excel sheet, where coloring on sheet 1 is conditioned based on C="Yes/No" and D = "Yes/No", meaning if C & D = Yes, color in B is Red and if C = No and D = Yes så B = Yellow. I need an automatic function where when options in C & D are selected and the color is changed in B, så the colored B must be positioned according to the coloring order: Red as high priority at the top, then Yellow, Orange, and green accordingly. Please find the JPEG below.
ExcelScreenDump
Thanks in advance, it is much appreciated.
BR
David
Unfortunately, the SORT tab does not update the list automatically. However, sorting with formula does update the list automatically, but cannot be so done using color.
You would have to sort a copy of list based on the Yes and No conditions, then apply the conditional formatting the sorted table based on a sorted copy of the Yes and No conditions.
I'm working on a large data file where on a monthly basis I have to check for any errors. I'm wanting to write a macro that allows for the following:
IF row G does not contain the value from E
OR row G does not contain the value from F
OR row G does not contain "#email.com"
Then change the cell color to purple
To clarify: E contains FirstName, F contains LastName, G contains emailadress with firstname.lastname#email.com. I'm looking for errors in the emailadress, where it may have been misspelled or the wrong format was used.
I'm not allowed to make permanent changes with formulas, therefore I'm looking for a macro that will let me change the colors and an IF ELSE that allows me to turn off the color afterwards.
What would be the best way to write this in VBA?
Thanks!
Select the email cells (ColG; in this example starting at G2) and add a formula-based Conditional Formatting rule using the formula:
=G2<>E2 & "." & F2 & "#email.com"
Make sure you use relative addresses in the formula (no $) - that way it will adjust for the other cells in the selected range in Col G.
I'm working on data-analysis where i would like to be able to automatize color fill when looking through large amount of data where there are abundant amount of ghost logs and taking too much of my time as they are severely irrelevant.
So what i would like to do in Excel, is to be able to color fill a cell when the number changes in a column marking a different set of logs.
For instance if there are six rows of log number 456455, i would like the code to color fill the first cell when the number changes to 456456 so that it helps me identify logs faster when i know where the sets are starting. I'm kind of a newbie when it comes to Excel but this loop would help me a lot!
Thx for your time
This can be done with conditional formatting. Use a rule that compares the current cell with the cell in the row above and format if the two are different. Note that you will need to use relative references without $ signs. In the screenshot below, the conditional format is applied from row 2 to 19 and in row 2 the formula compares A2 with A1, in the next row it compares A3 with A2, and so on. If the two cells are different, the cell will change colour.
If you have some knowledge in VBA, you can implement a macro that looks at the column where you have your log number and if the value changes from one cell to another, then you highlight this cell.
I attached a template of code that works for this task.
Sub highlightChange()
Dim preVal As Integer
preVal = 0
For Each o In Range("A:A")
'Go through column
If o.Value <> preVal Then
o.Interior.Color = vbRed 'Color the selection
End If
preVal = o.Value
Next o
End Sub
There may be other solution without VBA, however, it is quite easy and practical to use a macro.