VBA click counter

rapoza609

New Member
Joined
Oct 28, 2024
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I'm trying to do something that I feel should be rather easy to do, but simply isn't working.

I'm want to create multiple spin buttons to manually allow the user keep score of different things and to display the current count of each in separate text boxes. However I also want to display a total overall count of based on ALL spin button inputs.

I declared a total count variable as Long and it will change from 0 to 1 with the first click, but won't add any more with any additional clicks.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Something along these lines, assuming your buttons and textboxes are on a form?
VBA Code:
Private Sub SpinButton1_Change()
SpinButton1.Min = 0
SpinButton1.Max = 50
SpinButton1.SmallChange = 1
TextBox1.Value = SpinButton1.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
Private Sub SpinButton2_Change()
SpinButton2.Min = 0
SpinButton2.Max = 20
SpinButton2.SmallChange = 1
TextBox2.Value = SpinButton2.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
Private Sub SpinButton3_Change()
SpinButton3.Min = 0
SpinButton3.Max = 20
SpinButton3.SmallChange = 1
TextBox3.Value = SpinButton3.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
 
Upvote 0
Something along these lines, assuming your buttons and textboxes are on a form?
VBA Code:
Private Sub SpinButton1_Change()
SpinButton1.Min = 0
SpinButton1.Max = 50
SpinButton1.SmallChange = 1
TextBox1.Value = SpinButton1.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
Private Sub SpinButton2_Change()
SpinButton2.Min = 0
SpinButton2.Max = 20
SpinButton2.SmallChange = 1
TextBox2.Value = SpinButton2.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
Private Sub SpinButton3_Change()
SpinButton3.Min = 0
SpinButton3.Max = 20
SpinButton3.SmallChange = 1
TextBox3.Value = SpinButton3.Value
TextBoxTotal.Value = SpinButton1.Value + SpinButton2.Value + SpinButton3.Value
End Sub
This works, but the initial count goes from "0" to "2" and skips 1. How would I fix this? Thank you very much, by the way.
 
Upvote 0
Hard to say without seeing your code. Can you post your code?
 
Upvote 0

Forum statistics

Threads
1,223,385
Messages
6,171,780
Members
452,424
Latest member
Sheila003

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