View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Add break in macro

Thomp -

Here's a procedure which checks what color the clicked shape is, and assigns
the next color. Right click the shape, choose Assign Macro, and select
ChangeShapeColor from the list.

Sub ChangeShapeColor()

On Error GoTo ExitSub

With ActiveSheet.Shapes(Application.Caller)
Select Case .Fill.ForeColor.SchemeColor
Case 51
.Fill.ForeColor.SchemeColor = 11
Case 11
.Fill.ForeColor.SchemeColor = 13
Case 13
.Fill.ForeColor.SchemeColor = 10
Case 10
.Fill.ForeColor.SchemeColor = 51
Case Else
.Fill.ForeColor.SchemeColor = 51
End Select
End With

ExitSub:

End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Thomp" wrote in message
oups.com...
Let me first preface by saying I know very little VBA but what I am
wanting to do is to create a macro that changes an autoshape color
each time I click on the autoshape. The macro I have below just runs
from the first color to the last. I want to click the shape and change
the color on each click. In fact it needs to loop so that every time I
click the shape it moves between the four colors chosen. I guess I am
looking for some kind of macro break

Here is my code thus far.

ActiveSheet.Shapes("AutoShape 67").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 11
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 13
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 10
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 51
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid

thanks in advance
Thomp