Autoshape Mouse Over Macro

DJLA

New Member
Joined
Oct 19, 2006
Messages
5
I want to run a macro when the user runs the mouse over the surface of an Autoshape. What is the best way to do this?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

xapie128

Board Regular
Joined
Aug 26, 2006
Messages
82
Autoshapes only has the Click event.
There is a way around this limitation, but it depends on what you want to do with it...

Draw a Label (control toolbox) over the Autoshape, and set the Label's BackStyle property to Transparent.

Then use the MouseMove event for the Label.

Here's the downside: As the mouse moves across the Autoshape (Label), the SUB will execute many times. If you want it to turn something on or pop up a MsgBox then it should work okay for you. But if you want it to, say, add a number, it will do it multiple times with only one "visit" of the mouse over the Autoshape because it is seeing it "move" that is change X & Y mouse positions many times. You can get it to execute only once by using Label1.Visible = False but you will need to set it back to True when the mouse is not over the Label.
 

Forum statistics

Threads
1,141,095
Messages
5,704,311
Members
421,338
Latest member
Pepess

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
Top