Using buttons to increment

rjc4

Well-known Member
Joined
Nov 6, 2004
Messages
502
Hi All,
Still trying to figure out a solution to this. Have received some help from the forum (Mike) but not resolved.

I wish to use buttons, either spin or scroll to increment my cell by 1cent at a time. Spin buttons only allow for integers. So in my cell, say I have, 9.76, I wish to use buttons to scroll to 9.77, 9.78, 9.79 etc.

I know I can just use a list of numbers incremented by 1 cent, but this list can be very large if I need a range of say 1.00 to 50.00.

Is there any way to do this or am I stuck with a long list.

Thanks
RC
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You could attach something like this to the spinner:

Private Sub SpinButton1_SpinUp()
[a1].Value = [a1].Value + 0.01
End Sub
Private Sub SpinButton1_SpinDown()
[a1].Value = [a1].Value - 0.01
End Sub
 
Upvote 0
Hello tactps,

Thanks for your help. I've copied the code into the Excel objects Sheet, but I don't know how to "attach" the code to the spinner. A line appears between them so I assume that there are two subs, spin up and spin down?

I've placed a spinner button on my spreadsheet and I can see and change the properties through format control, but what do I do now.

Sorry if this is a dumb question.

Can you guide me further.
Thanks again,
RC
 
Upvote 0
Right-click on the spinner and choose "View Code". Then paste what I have in.

Note that you will need to determine if it is "SpinButton1". It may be another number if you have multiple spin buttons or deleted any.
 
Upvote 0
Hi tactps,

Thanks again.
First problem, was that I used the forms option to set up the spin button not the Control Toolbox. I've now copied the code in via the view code but it is still giving me problems.

This is what is happening. (E2 is my cell reference).

It is still counting in integers. For instance 33.01->34.01->35.01 etc.
also if I toggle the spin button directly from up to down and vice versa, it counts like this...
50.99->52.01 then 53.01, 54.01 etc. and 54.01->52.99 then 51.99 etc.

Can't see what is wrong. The code says get the cell contents and add or
subtract one cent to the existing contents. Am I doing something wrong.

Cheers
RC
 
Upvote 0

Forum statistics

Threads
1,203,146
Messages
6,053,755
Members
444,681
Latest member
Nadzri Hassan

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