I'm sure it's simple but cant figure out where I am going wrong. I have some previously existing code that works fine, but I don't know how to modify this to only apply these formatting conditions if another column contains certain values.
I have a report that is generated and the code below provides conditional formatting if the value in D = 0 and value in G>D, but I only want this to happen if the value in B contains any of the following values: EA, LF, VLF, SF or CY.
I have seen people add SEARCH(""Value"',$B2) but I do not know where I would add that and if I can add all those different values into the SEARCH function.
I have tried
"=AND($D2=0,$G2>$D2,SEARCH(""EA","LF","VLF","SF","CY"",$B2))"
And also tried it without the commas between each value.
Any advice would be appreciated.
Thank you!
Range("Table13[Week Ending Units]").Select
Application.CutCopyMode = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($D2=0,$G2>$D2)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 10066431
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
I have a report that is generated and the code below provides conditional formatting if the value in D = 0 and value in G>D, but I only want this to happen if the value in B contains any of the following values: EA, LF, VLF, SF or CY.
I have seen people add SEARCH(""Value"',$B2) but I do not know where I would add that and if I can add all those different values into the SEARCH function.
I have tried
"=AND($D2=0,$G2>$D2,SEARCH(""EA","LF","VLF","SF","CY"",$B2))"
And also tried it without the commas between each value.
Any advice would be appreciated.
Thank you!
Range("Table13[Week Ending Units]").Select
Application.CutCopyMode = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($D2=0,$G2>$D2)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 10066431
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False