VBA with Shapes & textbox events.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I have textbox and shapes in worksheet, can i make vba run/be activated when the mouse hover over the these object, and can I make different macro run with hovering on different objects? Please help me with the code...

Thanks alot for helping in advance.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
if they are activeX controls you can use the _mouseover event. not sure about sheet objects tho
 
Upvote 0
if they are activeX controls you can use the _mouseover event. not sure about sheet objects tho

Hi Diddi, okay, i'll use activex object. Can you give me a small example how to proceed further?

Thanks
Pedie
 
Upvote 0
sorry Pedie, i think i got my languages mixed up. i cant do it in vba without holding a button down on the mouse, which isnt much good. ill have to think about it.
 
Upvote 0
For ActiveX controls, have a look at the MouseMove event...
 
Upvote 0
If you simply want to run a particular code whenever the mouse moves across an ActiveX control, such as a text box, place the following code in the sheet module (or right-click the text box while in Design Mode and select View Code), and try...

Code:
[font=Verdana][color=darkblue]Private[/color] [color=darkblue]Sub[/color] TextBox1_MouseMove([color=darkblue]ByVal[/color] Button [color=darkblue]As[/color] [color=darkblue]Integer[/color], [color=darkblue]ByVal[/color] Shift [color=darkblue]As[/color] [color=darkblue]Integer[/color], [color=darkblue]ByVal[/color] X [color=darkblue]As[/color] [color=darkblue]Single[/color], [color=darkblue]ByVal[/color] Y [color=darkblue]As[/color] [color=darkblue]Single[/color])
     Call YourMacro
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]
 
Upvote 0
Domanic, thank you soo much...That is what I wanted. That was very good example...


Thanks again.
Happy weekends!:)
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,835
Members
452,947
Latest member
Gerry_F

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