conditional formatting 1004 errors
Is the sheet you are trying to apply the formats protected? If so, you need
to unprotect the worksheet first then reapply the protection.
Sub TEST()
' unprotect sheet first
Sheets("Sheet1").Unprotect Password:="password"
' your code
With Range("I10:I1000")
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(AND(ABS($J10)$G$5,ABS($I10)$G$4))"
.FormatConditions(.FormatConditions.Count).SetFirs tPriority
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = True
End With
' protect sheet
Sheets("Sheet1").Protect Password:="password"
End Sub
Hope this helps! If so, let me know by clicking YES below.
--
Cheers,
Ryan
"Sarah" wrote:
I'm a rookie. I am getting Run-time error '1004': Unable to set the Bold
property of the Font class with the following code:
Range("I10:I1000").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(AND(ABS($J10)$G$5,ABS($I10)$G$4))"
Selection.FormatConditions(Selection.FormatConditi ons.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Thank you
|