Forum Discussion
macro script conditional formatting
Hi Diana,
Could you please give bit more details what exactly doesn't work. In general good practice is one color-one rule for entire range, the rest is how do you apply the formula.
- Diana Delaney-FrancisNov 14, 2018Copper Contributor
I tried recording a macro with multiple conditional formatting. The end result should be that 1st for any date in column O occurring today the entire row should be shaded red, 2nd for any date in column occurring tomorrow the entire row should be shaded orange, and 3rd any date in column occurring this week then the entire row should be shaded light blue. Everything else remains unshaded. When I look at the macro script the the 2nd and 3rd options don't record and when I try to run the macro the red shading doesn't shade the correct rows.
- Diana Delaney-FrancisNov 19, 2018Copper Contributor
Hi Excel experts, I could really use some help with this macro. Pleaseeee
- John KeleherNov 14, 2018Copper Contributor
Alternatively you could code without conditional formatting:
Sub BackColor()
Mydate = Date
Select Case Cells(1, 15).Value
Case Mydate
Range("A1:O1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = vbRed
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Case DateAdd("d", 1, Mydate)
Range("A1:O1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = vbGreen
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Case Else
Range("A1:O1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = vbBlue
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End SelectEnd Sub
- Diana Delaney-FrancisNov 16, 2018Copper Contributor
I tried applying your code but it shaded the entire worksheet blue.