Hi Everyone,
I'm very new to Macros and I know very little about VBA. I have recorded over and over my macro. I set three different conditions so that it changes the font and background color depending on the keywords. The weird thing is that when I try to run the macro in another worksheet, it seems to have exchanged the font.color. I tried to change the code but...I failed.
I want the font color to be white for the A5:I71
RGB (156,0,6) for the range A5:M73
RGB (0,97,0) for the A5:K71
If you have any recommendations regarding ways to clean this up let me know,
Thanks!
Range("A5:I71").Select
Range("I5").Activate
ActiveWindow.SmallScroll Down:=-45
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""ReImbusement"",$I5=""Trade"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
Selection.FormatConditions(1).StopIfTrue = False
ActiveWindow.SmallScroll Down:=12
Cells.FormatConditions.Delete
Range("A5:M73").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""Master Card"",$I5=""Other"",$I5=""Visa"",$I5=""ATM"",$I5=""Charge"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A5:K71").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""Cash"",$I5=""Money Order"",$I5=""Check"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A5:I71").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""ReImbursement"",$I5=""Trade"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
Selection.FormatConditions(1).StopIfTrue = False
ActiveWindow.SmallScroll Down:=24
End Sub
I'm very new to Macros and I know very little about VBA. I have recorded over and over my macro. I set three different conditions so that it changes the font and background color depending on the keywords. The weird thing is that when I try to run the macro in another worksheet, it seems to have exchanged the font.color. I tried to change the code but...I failed.
I want the font color to be white for the A5:I71
RGB (156,0,6) for the range A5:M73
RGB (0,97,0) for the A5:K71
If you have any recommendations regarding ways to clean this up let me know,
Thanks!
Range("A5:I71").Select
Range("I5").Activate
ActiveWindow.SmallScroll Down:=-45
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""ReImbusement"",$I5=""Trade"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
Selection.FormatConditions(1).StopIfTrue = False
ActiveWindow.SmallScroll Down:=12
Cells.FormatConditions.Delete
Range("A5:M73").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""Master Card"",$I5=""Other"",$I5=""Visa"",$I5=""ATM"",$I5=""Charge"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A5:K71").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""Cash"",$I5=""Money Order"",$I5=""Check"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A5:I71").Select
Range("I5").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($I5=""ReImbursement"",$I5=""Trade"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
Selection.FormatConditions(1).StopIfTrue = False
ActiveWindow.SmallScroll Down:=24
End Sub