Run macro on 'Mouse Over'

lukeshuttlewood

Board Regular
Joined
Jul 27, 2004
Messages
90
Hi

Is it possible to run code on mouse over event in Excel vba?

I would like to be able run some code using an object (square, circe or whatever) on a sheet (specifically not a user form!).

Cheers
Luke
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
It's possible to create a commandbutton on a worksheet and use the mouse over event for that item. I've never had much luck with the mouse over event because it tends to run multiple times when the curser moves across the item. There is a control toolbox toolbar that has all the same tools as a userform. That should get you started.
 
Upvote 0
I don't think you can trigger an event from mouseover using a shape on a sheet. I think you can only assign an event to the Click for a shape.

However, you can use the mouseover event for an object you have placed onto a sheet. For what you want to do, I would suggest inserting an image onto your spreadsheet.

First, make sure the Visual Basic toolbar is visible (use View .. Toolbars if not)

Next, turn on Design Mode and the Control Toolbox using the buttons on the VB toolbar.

Now, insert an image object from the Control Toolbox.

If you view the properties of this new image (right click it) you can select border and background images for it. If you wanted a circle, you could set the bitmap to be the image of a circle created in any simple art package.

To assign a macro to it, either right click and show code, or double click it. The default is the Click event, but you will be able to select others from the drop down box in the top right of the code window. There is no mouseover event, but mousemove does something very similar.

If you want any more help with this, let me know
 
Upvote 0

Forum statistics

Threads
1,215,963
Messages
6,127,964
Members
449,414
Latest member
sameri

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