Changing BackColor of Pattern (VBA)

bvokey

New Member
Joined
Jun 1, 2015
Messages
35
I am using the following code to change the forecolor of a pattern:
'Change to Red

Sub Code()
i = ActiveSheet.Shapes.Range(Array(ButtonName)).Fill.BackColor.RGB
Pattern = ActiveSheet.Shapes.Range(Array(ButtonName)).Fill.Pattern
With ActiveSheet.Shapes.Range(Array(ButtonName)).Fill
If i = 255 Then 'If i is red then turn to white
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.BackColor.ObjectThemeColor = msoThemeColorBackground1
.BackColor.TintAndShade = 0
.BackColor.Brightness = 0
.Patterned Pattern
T = 0
'Exit Sub
End If
If i=16777215 Then 'If i is white, turn to blue
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.BackColor.RGB = RGB(0, 176, 240)
.Patterned Pattern
T = 1
Exit Sub
End If
If i=15773696 Then 'If i is blue, turn to red
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.BackColor.RGB = RGB(255, 0, 0)
.Patterned Pattern
T = 2

End If
End With
ActiveSheet.Range("J21").Select
End Sub

These codes work perfectly fine, however, when i try to run it again, the "i" variable doesnt change to the new back color value. Anyone have any idea why?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,410
Messages
6,124,756
Members
449,187
Latest member
hermansoa

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