G
Gazza
Hi,
I'm a relative newcomer to VB, but I'm stuck on the following problem:
I have a 10 x 10 multiplaction square, than when each square is clicked
on, the font changes colour, and the answer appears. To assign the macro
though, I created 100 autoshape rectangles and lined them up over my
10x10 squares, then used code such as:
Sub Rectangle1_Click()
Range("B2").Select
Call Color_Change
End Sub
Sub Rectangle2_Click()
Range("C2").Select
Call Color_Change
End Sub
Sub Rectangle3_Click()
Range("D2").Select
Call Color_Change
End Sub
....
Sub Color_Change()
cell(va, va).Select
col = Selection.Font.ColorIndex
If col = 1 Then
Selection.Font.ColorIndex = 2
Else
Selection.Font.ColorIndex = 1
End If
End Sub
Now the range().select is hard-coded into each sub (giving a lot of
subs), and I can't work out how to get a connection between the shape
that was clicked (even by using topleftcell.address) and the cell I need
to change the font in. Surely there's a neater way of doing what I've
got?
Thanks
I'm a relative newcomer to VB, but I'm stuck on the following problem:
I have a 10 x 10 multiplaction square, than when each square is clicked
on, the font changes colour, and the answer appears. To assign the macro
though, I created 100 autoshape rectangles and lined them up over my
10x10 squares, then used code such as:
Sub Rectangle1_Click()
Range("B2").Select
Call Color_Change
End Sub
Sub Rectangle2_Click()
Range("C2").Select
Call Color_Change
End Sub
Sub Rectangle3_Click()
Range("D2").Select
Call Color_Change
End Sub
....
Sub Color_Change()
cell(va, va).Select
col = Selection.Font.ColorIndex
If col = 1 Then
Selection.Font.ColorIndex = 2
Else
Selection.Font.ColorIndex = 1
End If
End Sub
Now the range().select is hard-coded into each sub (giving a lot of
subs), and I can't work out how to get a connection between the shape
that was clicked (even by using topleftcell.address) and the cell I need
to change the font in. Surely there's a neater way of doing what I've
got?
Thanks