Recorded Macro changing format of conditional formatting

gouga78

New Member
Joined
Feb 5, 2016
Messages
1
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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top