rsadambrown
New Member
- Joined
- Feb 14, 2019
- Messages
- 2
Hi everyone! I'm looking at throwing in some conditional formatting to a macro I am writing. The range is dynamic and can change, and the conditional formatting is based off of another cell. I've tried recording the macro and copy+pasting that result, but the result is just making the entire selection red, instead of just the cells that meet the condition. I've tried some searching on here and in google, to no avail.
Here's a code sample. When stepping threw the macro, the first two lines select the range correctly, but when selection.style is executed, it just makes the whole range 'bad'. The intent is just to make any value in the range > the value in cell C25 on the 'Macro' tab 'bad'.
Thanks, and I appreciate any help!
Here's a code sample. When stepping threw the macro, the first two lines select the range correctly, but when selection.style is executed, it just makes the whole range 'bad'. The intent is just to make any value in the range > the value in cell C25 on the 'Macro' tab 'bad'.
Code:
Set TestArea = Application.Range(Cell1:="G2", Cell2:="G" & EndingDown)TestArea.Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="=Macro!$C$25"
Selection.Style = "Bad"
Thanks, and I appreciate any help!