Multiple Reset Buttons

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12
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?
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,830
Office Version
  1. 2013
Platform
  1. Windows
If you ever have a script written that does not do what you want. You need to show us the script so we can see why it does not work.

And show us all the code you have in your sheet.
 

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12
If you ever have a script written that does not do what you want. You need to show us the script so we can see why it does not work.

And show us all the code you have in your sheet.
 

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12

ADVERTISEMENT

I can't get a link for a picture to upload. And I don't know where to find the code that is causing this. All I have is the code that resets all of the cells, and I know that is not want you want. So, what next?
 

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12
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()
End Sub
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,830
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

You said:
I have created an Active x control reset button on a worksheet to clear certain cells.

So you created a Button and have code in it to clear cells but you do not know where the code is?

Right click on the Control and select view code if in developer mode.

Or right click on sheet tab and choose view code.

 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,830
Office Version
  1. 2013
Platform
  1. Windows
Now you showed me your code:
Private Sub CommandButton2_Click()
'You need some code in here


End Sub

This button has nothing in it:

It cannot do anything if it has no code
 

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12
I have placed code under there, but then it affects all the buttons, not just one. What I want is three buttons on a single sheet. I want the first button to clear information in a certain set of cells, the second button to clear another specific set of cells, and then the third button to clear all cells on the sheet. The code I have listed is the code to clear once set of cells on the page. When I try to create a new button, the code is duplicated in the code, so all three buttons are clearing exactly the same thing, which is the everything I want deleted and not just the specific set of cells.
 

supermanjohn01

New Member
Joined
Jul 10, 2018
Messages
12
So, and I've tried this, but I think I'm not separating them, naming them or differentiating between them properly for them to work. I have tried to place different code for clearing the cells, but either all the buttons clear the same thing, or one button works and the other two do not. Does the code for all three buttons show up in the same box? When I did this before, I had two different boxes pop up (one for each button), and they each had their own separate code.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,037
Messages
5,526,397
Members
409,701
Latest member
nitmani

This Week's Hot Topics

Top