Run command button in another command button

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
311
Office Version
  1. 365
Platform
  1. Windows
I have a command button on Sheet1, Private Sub CommandButton1_Click(). On sheet2 I also have a command button, also called Private Sub CommandButton1_Click()

How do I get the button on sheet2 to also run the button on sheet1 when its pressed?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
To have several Private Sub CommandButton1_Click()
Scripts to perform the same script

Write a Module script like this:


VBA Code:
Sub Do_This()
'Modified 11/12/2021  10:36:13 AM  EST
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(Lastrow, 1).Value = "Alpha"
End Sub

Then in each Private Sub CommandButton1_Click() buttons
Put this

Call Do_This
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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