Combined Spin Button Maximum

Crankylemming

New Member
Joined
May 28, 2019
Messages
2
Hi

I've been asked to create an interactive worksheet so that users can use "sliders" (by which I'm assuming spin buttons or scroll controls) can distribute £60,000 across up to 6 different sectors, one 'slider' per sector.

I have:

Cells B1:B6 linked to spin buttons 1-6
The £60 (I shrank it down for testing to make using the spin control quicker) figure in cell H1
The combined total of B1:B6 in cell H2
The figure of H1 - H2 in cell H3

Each spin button has a version of this -

Code:
Private Sub SpinButton1_Change()
ActiveSheet.SpinButton1.Max = Range("H3").Value
End Sub

What I get is SpinButton1 goes to a maximum of 30; SpinButton2 to a maximum of 15; 3 to 7 etc. I'm obviously doing something wrong, so please could anyone advise how I combine the values on the spin buttons to a single variable maximum?

Thank you in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to the MrExcel Board.

You're including the active cell in the "used" amount. You'd need to do something like:

Code:
Private Sub SpinBUtton1_Change()
    ActiveSheet.SpinButton1.Max = Range("H1").Value - Range("B2").Value - Range("B3").Value - Range("B4").Value - Range("B5").Value - Range("B6").Value
End Sub
 
Last edited:
Upvote 0
Wouldn't SpinButton1's maximum be set by the Change events for SpinButton2 and SpinButton3, but be unchanged by SpinButton1_Change?
 
Upvote 0
Of course I was! So obvious now!

Thank you Eric, that's brilliant - I added the code for the other buttons, leaving out their own range, and all works perfectly.

Thank you for your help!

Steve


Welcome to the MrExcel Board.

You're including the active cell in the "used" amount. You'd need to do something like:

Code:
Private Sub SpinBUtton1_Change()
    ActiveSheet.SpinButton1.Max = Range("H1").Value - Range("B2").Value - Range("B3").Value - Range("B4").Value - Range("B5").Value - Range("B6").Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,020
Messages
6,122,709
Members
449,093
Latest member
Mnur

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