Run macro in loop while holding down left mouse button (digital clock example)

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
437
Good day, I have built a digital click on an Excel userform where the time is manipulated using the up/down arrows. The first set of arrows (on the left) manipulate the first two positions (hours) and the second set of arrows (on the right) manipulate the second two positions (minutes). There are several images of numbers whose visibility property is set to TRUE/FALSE as the arrows are clicked. My basic strategy was to combine the first two numbers in a single number (e.g. 0 and 9 becomes 09), adjust that number up or down, and again deconstruct. I got this to work for both sections, so no problem there.

The thing is, I want the user to be able to quickly adjust the numbers. For example, the pic shows 58 minutes - if I want to get to 32 minutes, I'd rather not click the down arrow on the right 24 times. I'd like to be able to hold down the arrow button and quickly get down to that number - what are my options here?

1594671852293.jpeg
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You might consider reading the status of the CTRL , ALT or SHIFT key. If it was pressed while clicking on the arrow, perform steps of 10 instead of 1 single step.
Way back Chip Pearson wrote an article about how to obtain the states of those keys.
 
Upvote 0
That doesn't sound like too bad of an idea, even though the code looks like a lot of globbity-goop. I've put off digging into the Windows API! Thanks!
 
Upvote 0
Or you could use 4 sets of up/down arrows, instead of 2, one for the tens and one for the units for both the hours and minutes.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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