Spin Button Alternative?

eddiev1972

New Member
Joined
Mar 22, 2010
Messages
38
This is more of a VBA learning exercise than anything else:

I want to be able to create button that will continuosly increment/decrement a value while the button is depressed. (Similar to how a spin button works.)

This is primarily because a button will allow you to put a picture on it and spin button (seemingly) doesn't

I have tried the mousedown event and it will increment the value once. So there is either something I don't understand with the event, or I have ommitted the code needed for continuous function.

Any thoughts? Is this possible?

Thank you in advance for any guidance.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this:-
"A1" is incremented by 1 until you lift your finger from the commandButton , When The "MouseUp" event triggers and "a1" is returned to "1"
Code:
Option Explicit
Dim Go As String
Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Go = "Go"
Do While Go = "Go"
DoEvents
[a1] = [a1] + 1
Loop
End Sub
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Go = "Stop"
[a1] = 0
End Sub
Mick
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,047
Members
448,940
Latest member
mdusw

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