Macro to confine cursor to set boundaries

mackensteff

Board Regular
Joined
Feb 9, 2010
Messages
74
Office Version
  1. 365
Platform
  1. MacOS
Hello,

Is it possible by vba to restrict the mouse movements to a given area of the screen. Ideally, I would like the cursor to be confined to a large button area once the button is pressed and triggers a macro, but by pressing esc or a similar key regain free movement, but then be confined to the button area once it is pressed again. Is this remotely possible (or does that even make sense)?

Thanks!!
 
I did mean the cursor, but the idea of a limited scroll area will work as well. I am using a button and macro to record times, and once I have started timing I don't want the cursor to wander off the button, unless I escape out. I am not necessarily watching the screen, so if I move the cursor off the button accidentally then pressing a mouse button won't record the time. So in essence I am trying to idiot proof the timing button, so once engaged the cursor will not move off it, and like I mentioned I think the limited scroll would work, if I could get it to work. I have attached a workbook, with no data, just the macro and button, if you want to check and identify my source of ineptitude. https://www.dropbox.com/s/blzj8fturd583i6/Trial.xlsm?dl=0

Thanks
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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