Shapes do not have mousemove events, but active-x objects do.
The workaround is to add 2 active-x labels and use their respective mousemove events to change the shape's colour. Both labels sit behind the shape. Label2 is bigger than Label1, Label1 is bigger than the shape. Label2 mousemove sets shape default colour. Label2 mousemove sets hover-over colour.
Method - Try this in a NEW workbook first to practice the method
1. Insert a shape - use the first Rectangle - expect it to be auto-named "
Rectange 1"
2. On Developer's tab
- Insert (Active-X) Label
- click on worksheet (away from rectangle) to insert it (expect this to be auto-named
Label1) and make it larger than the shape
- Insert (Active-X) Label
- click on worksheet to insert it (expect this to be auto-named
Label2) and make it larger than Label1
- click on sheet tab \
View Code \ paste code below into VBA window
Code:
Private Sub [COLOR=#000080]Label1[/COLOR]_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'a red colour
ActiveSheet.Shapes("[COLOR=#ff0000]Rectange 1[/COLOR]").Fill.ForeColor.RGB = RGB(192, 0, 0)
End Sub
Private Sub [COLOR=#000080]Label2[/COLOR]_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'a blue colour
ActiveSheet.Shapes("[COLOR=#ff0000]Rectangle 1[/COLOR]").Fill.ForeColor.RGB = RGB(0, 32, 96)
End Sub
3. {ALT} {F11} takes you back to workbook
4. Switch
off Design Mode (by clicking on the Design Mode button)
5. Hover mouse over both labels - move to step6 only the shape's colour is changed by both
6. Switch
on Design Mode
7. Move
Label1 over top of shape \ right-click \
Order \
Send-To-Back
8. Right-click on
Label1 \ Properties \ amend
BackStyle to Transparent & delete text in
Caption
9. Repeat for
Label2
10. Use {CTRL} to select all 3 objects \ right-click \
Group \
Group (all can now be moved together)
11. Switch
off Design Mode and test
After testing, adapt for live workbook amending the values to suit your own requirements (Shape name is different, Label names may be different, colour choice etc)
Let me know how you get on