Hello,
I have a worksheet called Sheet2 with 75 freeform items. Each shape is called Shape1, Shape2, Shape3 ... Shape75.
I would like to change the color of the shape everytime the shape is clicked. I have no preference to the colours, but to give you an idea of what I mean, each time the shape is clicked, the color will change as follows;
Black
Blue
Brown
Red
Orange
Yellow
White
And then start back at Black if all the colors have been chosen. At present, I have attached a bit of code to each shape which calls the following function
The code attached to the shape is;
Although I have done all the coding and the document seems to work as I would have liked, there must be a better way to do it?
Thanks
Indi
I have a worksheet called Sheet2 with 75 freeform items. Each shape is called Shape1, Shape2, Shape3 ... Shape75.
I would like to change the color of the shape everytime the shape is clicked. I have no preference to the colours, but to give you an idea of what I mean, each time the shape is clicked, the color will change as follows;
Black
Blue
Brown
Red
Orange
Yellow
White
And then start back at Black if all the colors have been chosen. At present, I have attached a bit of code to each shape which calls the following function
Code:
Sub ColorChanger()
Sheets("sheet3").Range("A" & i).Value = Sheets("sheet3").Range("A" & i).Value + 1
CellRef = Sheets("sheet3").Range("A" & i).Value
Select Case CellRef
Case 1
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(255, 0, 0)
Case 2
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(0, 255, 0)
Case 3
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(0, 0, 255)
Case 4
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(255, 255, 0)
Case 5
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(0, 100, 100)
Case 6
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 0.5
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(255, 0, 255)
Case 7
Sheets("sheet3").Range("A" & i).Value = 0
Sheets("sheet2").Shapes("Shape" & i).Fill.Transparency = 1#
Sheets("sheet2").Shapes("shape" & i).Fill.ForeColor.RGB = RGB(255, 255, 255)
End Select
End Sub
Code:
Sub Shape1_Click()
i = 1
Call ColorChanger
End Sub
Sub Shape2_Click()
i = 2
Call ColorChanger
End Sub
Although I have done all the coding and the document seems to work as I would have liked, there must be a better way to do it?
Thanks
Indi