Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vis. Basic In Excel Changing the Color of Shapes

Status
Not open for further replies.

campbemr

Technical User
Aug 16, 2001
19
US
In an excel spreadsheet there are shapes and I need to be able to change the color of the shape when I click on the shape. Like if I click the shape it automatically changes to blue. Then when I click it again it changes to red. These colors will be predetermined. How can this be done?
 
Assuming there is a rectange object on the active sheet named "Rectangle 1", you can create a macro that executes on its click event:

ActiveSheet.Shapes("Rectangle 1").Select
'sets the color index in the current color scheme. Selection.ShapeRange.Fill.ForeColor.SchemeColor = 2
' or via RBG method
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(12, 23, 222)

Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top