Activate Macro When Cursor Goes Over a Shape

MikeG

Well-known Member
Joined
Jul 4, 2004
Messages
845
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a shape called Oval1.

I would like to set things up so that if a user points the cursor over the shape, then a macro will be activated.

I know how to set things up to activate if the user clicks on the shape:

Sub Oval1_Click()
Do my stuff
End Sub

However, in this new case, I do not want them to have to click - just pass over the shape.

Could someone give me the basic macro-form? Is it a macro associated with the worksheet, as opposed to the shape itself?

Thanks,

MikeG
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Thanks Peter - I'll read through.

Mikeg
 
Upvote 0
Actually, if I just wanted to activate the macro when I move over a cell - say C10 - could anyone tell me the relevant code?

Thanks,

MikeG
 
Upvote 0
Similar problem - there is no MouseOver code for a cell or range as far as I am aware.
 
Upvote 0
Thanks again Peter. When does "MouseOver" apply?

MikeG
 
Upvote 0
The best way I know of is to encapsulate this within a separate component so your workbook is not bogged down by a polling timer. I have one that you are welcome to. Just shoot me a PM if you are interested. It's a simple dll that throws events to your worksheet and passes the object (Range or Shape or OleObject) that the mouse is currently over. You will have to distribute the dll with your workbook.
 
Upvote 0
Depending on what you are trying to do with your macro, you might just use a BeforeDoubleClick event. It's really less annoying than a Mouseover or Selection because it takes deliberate action to fire the code.

lenze
 
Upvote 0
Unless he after affects or some other reason that one might use hot tracking. You can do some really cool things with maps for example, using hot tracking over shapes. Charts provide some of this functionality I think though I am not familiar with it.l
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,291
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top