Hi I am trying to create a spreadsheet with many variables, and want them all to conditionally format when they auto-populate various other worksheets. The auto-formatting will vary from sheet to sheet dependant on primary user preferences, but the template will be the same for all. I am having issues with the template though, as I can only get the first 3 commands to run on it? Can anyone out there fix it as I am a total newb on VBA, and have taught myself everything I know on it in the last 2 days...
Any help would be much appreiciated,
Cheers,
oli
Here is the macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 09/06/2011 by SMITHSO
'
'
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=""A00""", Formula2:="=""A99"""
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 45
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=""B00""", Formula2:="=""B99"""
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(2).Interior.ColorIndex = 13
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD1"""
With Selection.FormatConditions(3).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(3).Interior.ColorIndex = 12
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD2"""
With Selection.FormatConditions(4).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(4).Interior.ColorIndex = 5
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD3"""
With Selection.FormatConditions(5).Font
.Bold = True
.Italic = False
.ColorIndex = xlAutomatic
End With
Selection.FormatConditions(5).Interior.ColorIndex = 37
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD4"""
With Selection.FormatConditions(6).Font
.Bold = True
.Italic = False
.ColorIndex = 6
End With
Selection.FormatConditions(6).Interior.ColorIndex = 41
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD5"""
With Selection.FormatConditions(7).Font
.Bold = True
.Italic = False
.ColorIndex = 10
End With
Selection.FormatConditions(7).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD6"""
With Selection.FormatConditions(8).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(8).Interior.ColorIndex = 1
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD7"""
With Selection.FormatConditions(9).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
Selection.FormatConditions(9).Interior.ColorIndex = 35
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD8"""
With Selection.FormatConditions(10).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(10).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD9"""
With Selection.FormatConditions(11).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(11).Interior.ColorIndex = 7
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD10"""
With Selection.FormatConditions(12).Font
.Bold = True
.Italic = False
.ColorIndex = xlAutomatic
End With
Selection.FormatConditions(12).Interior.ColorIndex = 38
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FIELD11"""
With Selection.FormatConditions(13).Font
.Bold = True
.Italic = False
.ColorIndex = 4
End With
Selection.FormatConditions(13).Interior.ColorIndex = 1
End Sub
Bookmarks