Hello, I am trying to write a macro but I'm getting stuck as I keep getting an error.
What I want to happen is looking at my range A1:P1000, if P1 = 0, then format the whole row (A:P) with italics, strikethrough text, and grey background. And etc for P2, P3, etc would format THAT row.
This is what I have, but I think there is an error in the lines I put in red. I am getting the "Run-time error '438' :Object doesn't support this property or method"
Sub ZeroFormat()
'
' ZeroFormat Macro
'
'
With Range("A1:P1000")
.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(COUNTBLANK($P1)=0,$P1=0)"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
.Font.Italic = True
.Font.Strikethrough = True
End With
End With
End Sub
What I want to happen is looking at my range A1:P1000, if P1 = 0, then format the whole row (A:P) with italics, strikethrough text, and grey background. And etc for P2, P3, etc would format THAT row.
This is what I have, but I think there is an error in the lines I put in red. I am getting the "Run-time error '438' :Object doesn't support this property or method"
Sub ZeroFormat()
'
' ZeroFormat Macro
'
'
With Range("A1:P1000")
.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(COUNTBLANK($P1)=0,$P1=0)"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
.Font.Italic = True
.Font.Strikethrough = True
End With
End With
End Sub