Button Command

levanoj

Active Member
Joined
Oct 25, 2007
Messages
311
Hello All,

I'm trying to create a button of some sort (that I would label as "Page Down") on my spreadsheet where everytime it get's pressed, it increases the number value of cell A1 (which has a value of 1) by 36.
So for example, if I press it once, the value in A1 changes to 37, press it again, it changes to 73, etc..

One rule however, the maximum the value A1 should ever reach is 577.

Can anyone help?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Sub PageDown()
Range("A1").Value = WorksheetFunction.Min(Range("A1").Value + 1, 577)
End Sub
 
Upvote 0
NJIMACK

the macro seems to work but is only increaseing the value by 1. I need it to be increased by 36 to a max of 577. Anyway this can be revised?

Also, is there anyway I can create a button for this command and place it on the actual spreadsheet? Like in Column U Row 5 for example?
 
Upvote 0
Sorry, I misread your original post.

Sub PageDown()
Range("A1").Value = WorksheetFunction.Min(Range("A1").Value + 36, 577)
End Sub

Create a button from the Forms toolbar, and place it on your sheet. Right-click the button, choose 'Assign macro', and select PageDown
 
Upvote 0
that worked perfect this time. Could you provide the same type of macro but which does the opposite?

So basically whatever value is in cell A1, whenever the button is pressed, it reduces the value numerical by 36.

For example if A1 is 577 then the next value would be 541 when the button is pressed.
The only rule with this command would be that the lowest value in A1 would be 1.
 
Upvote 0
Sub PageUp()
Range("A1").Value = WorksheetFunction.Max(Range("A1").Value - 36, 1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,544
Messages
6,120,126
Members
448,947
Latest member
test111

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