The spreadsheet I'm working on pulls data from an oracle database and automatically populates cells for which there is no data with "999999." I am attempting to use an excel macro to essentially gray-out all cells that contain this value with the intention of saving users the time it takes to apply conditional formatting to the cells manually each time. I used Excel's "record macro" feature to arrive at the code below, but I get an "Application-defined orobject-defined error" each time. Does anyone know why I continue to get the error and how I might fix the issue in the code below? Thanks in advance for any help.
Sub gray()
'
' gray Macro
'
'
Cells.Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=999999"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub Software/Hardware used:
ASKED:
March 11, 2009 6:47 PM
UPDATED:
March 13, 2009 7:09 AM