Multiple Reset Buttons

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
26
I have created an Active x control reset button on a worksheet to clear certain cells. I have tried to create another reset button, yet when I do, it has the same cells listed to clear, but doesn't work. And when I make changes to one button, it changes the contents of both. How can I create two buttons on the same worksheet, but that clear different cells?
 
Ok. I've listed the code again below for two buttons. For some reason now, Commandbutton3 doesn't work now, but Commandbutton2 does. This is my dilemma.


Private Sub CommandButton3_Click()

Sheets("Calculate").Range("D29").Value = "Bus Type"
Sheets("Calculate").Range("D31").Value = "Bus Type"
Sheets("Calculate").Range("D33").Value = "Bus Type"
Sheets("Calculate").Range("F29").Value = ""
Sheets("Calculate").Range("H29").Value = ""
Sheets("Calculate").Range("J29").Value = ""
Sheets("Calculate").Range("L29").Value = ""
Sheets("Calculate").Range("O29").Value = ""
Sheets("Calculate").Range("R29").Value = ""
Sheets("Calculate").Range("F31").Value = ""
Sheets("Calculate").Range("H31").Value = ""
Sheets("Calculate").Range("J31").Value = ""
Sheets("Calculate").Range("L31").Value = ""
Sheets("Calculate").Range("O31").Value = ""
Sheets("Calculate").Range("R31").Value = ""
Sheets("Calculate").Range("F33").Value = ""
Sheets("Calculate").Range("H33").Value = ""
Sheets("Calculate").Range("J33").Value = ""
Sheets("Calculate").Range("L33").Value = ""
Sheets("Calculate").Range("O33").Value = ""
Sheets("Calculate").Range("R33").Value = ""

End Sub

Private Sub CommandButton2_Click()
Sheets("Calculate").Range("C2").Value = ""
Sheets("Calculate").Range("G2").Value = ""
Sheets("Calculate").Range("L2").Value = ""
Sheets("Calculate").Range("D4").Value = ""
Sheets("Calculate").Range("D6:S6").Value = ""
Sheets("Calculate").Range("D7:S7").Value = ""
Sheets("Calculate").Range("D8:S8").Value = ""
Sheets("Calculate").Range("D9").Value = ""
Sheets("Calculate").Range("D11:S11").Value = ""
Sheets("Calculate").Range("D12:S12").Value = ""
Sheets("Calculate").Range("D13:S13").Value = ""
Sheets("Calculate").Range("B17").Value = ""
Sheets("Calculate").Range("D17").Value = ""
Sheets("Calculate").Range("F17").Value = ""
Sheets("Calculate").Range("H17").Value = ""
Sheets("Calculate").Range("J17").Value = ""
Sheets("Calculate").Range("N17").Value = ""
Sheets("Calculate").Range("P17").Value = ""
Sheets("Calculate").Range("S17").Value = ""
Sheets("Calculate").Range("B20").Value = ""
Sheets("Calculate").Range("B22").Value = ""
Sheets("Calculate").Range("B24").Value = ""
Sheets("Calculate").Range("U14:X14").Value = ""
Sheets("Calculate").Range("U16:X16").Value = ""
Sheets("Calculate").Range("U17:W17").Value = ""
Sheets("Calculate").Range("U18:W18").Value = ""
Sheets("Calculate").Range("U20:X20").Value = ""
Sheets("Calculate").Range("U21:X21").Value = ""
Sheets("Calculate").Range("G24").Value = ""
Sheets("Calculate").Range("B25").Value = ""
Sheets("Calculate").Range("B26").Value = ""
Sheets("Formulas").Range("B5:H5").Value = "FALSE"
Sheets("Formulas").Range("B9:H9").Value = "FALSE"


End Sub
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
All these two scripts seem to be doing is clearing ranges. Mostly.

If your new to Vba why not create two buttons and only add about three lines of code and then then press the button and see what happens.

And then when you see how things work go back and add the code the code you want.

Is that all your wanting the code to do is clear these ranges?

Did you write all this code?

Are you brand new to using Vba?
 
Upvote 0
I actually did that. I deleted ALL of the buttons and then started over with a small sample of code, but the same thing happened. Only one button works at a time. The only reason I added that much code with it NOT working was to show you what I was basically trying to accomplish. And yes, I am VERY new to VBA. What would keep both buttons from working and clearing different things?
 
Upvote 0
In that simple code you made for three different buttons show me all that code.

I think I mentioned before if you have problems with code you always need to show us the code.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,029
Members
452,542
Latest member
Bricklin

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