How do I create two buttons in Excel that I can name?

sixela

New Member
Joined
Dec 24, 2023
Messages
1
Office Version
  1. 365
Hello! I am trying to create an increase button that I can name "increase" and a decrease button I can name "decrease". I cannot use the spin button since I need to name the buttons and I need to learn this skill for future work projects. I need buttons to increase and decrease cell B5. Any help is appreciated! Thank you
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Two Buttons, one piece of code.
One Forms Control Button has the Caption "Increase" (no double quotes) and the other Forms Control Button has the Caption "Decrease"
VBA Code:
Sub Add_Or_Delete()
Select Case ActiveSheet.Buttons(Application.Caller).Caption
    Case "Increase"    '<---- Same spelling as the text ( = Caption) on the one Button
        Range("B5").Value = Range("B5").Value + 1
    Case "Decrease"    '<---- Same spelling as the text ( = Caption) on the other Button
        Range("B5").Value = Range("B5").Value - 1
End Select
End Sub
 
Upvote 0
Again, same restrictions for Button Captions.
Same code for both Buttons.
Code:
Sub Or_So()
    Cells(5, 2).Value = IIf(ActiveSheet.Buttons(Application.Caller).Caption = "Increase", Cells(5, 2).Value + 1, Cells(5, 2).Value - 1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,138
Members
449,098
Latest member
Doanvanhieu

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