Running multiple macros with one command button on userform

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
578
Hi, I'm trying to run the following macros from a userform but continues to get an error each time I try:

Private Sub CommandButton1_click()
Call Worksheets("Sheet1").CommandButton11_click
Call Worksheets("Sheet1").CommandButton12_click
Call Worksheets("Sheet1").CommandButton13_click
Call Worksheets("Sheet1").CommandButton14_click

End Sub

The error received is:

Run-time error '438'
Object doesn't support this property or method

Thanks for your help.
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,251
Office Version
  1. 2013
Platform
  1. Windows
All those Private Sheet scripts change them to Public like this:
Code:
Public Sub CommandButton1_Click()
MsgBox "Hello"
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,755
Office Version
  1. 365
Platform
  1. Windows
Are those commandbuttons on a sheet called sheet1?
And are they ActiveX command buttons?
 
Last edited:

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
578

ADVERTISEMENT

Fluff, that is correct.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,755
Office Version
  1. 365
Platform
  1. Windows
In that case as long as your removed the "Private" from the start of the procedure names. Your code should work.
 

My Aswer Is This

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

ADVERTISEMENT

Show us the actual scripts. There may be something wrong with the scripts.
 

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
578
This is the code I'm using...

Public Sub CommandButton1_Click()

Call Sheets("Sheet1").CommandButton11_Click 'Macro1
Call Sheets("Sheet1").CommandButton12_Click 'Macro2
Call Sheets("Sheet1").CommandButton13_Click 'Macro3
Call Sheets("Sheet1").CommandButton14_Click 'Macro4

End Sub
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,251
Office Version
  1. 2013
Platform
  1. Windows
I want to see the code in the Button.

The button must have some code in it.
 

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
578
Got it, here you go....thanks for your help.

Private Sub CommandButton11_Click()
If Range("os56") = 0 Then
Range("AA81:AA81").Select
Range("AA81:AA81").Activate
Selection.RowHeight = 0.000001
Range("AA82:AA82").Select
Range("AA82:AA82").Activate
Selection.RowHeight = 0.000001
Range("AA83:AA83").Select
Range("AA83:AA83").Activate
Selection.RowHeight = 0.000001

Range("os56") = 4
Else
Range("AA81:AA81").Select
Range("AA81:AA81").Activate
Selection.RowHeight = 12.75
Range("AA82:AA82").Select
Range("AA82:AA82").Activate
Selection.RowHeight = 12.75
Range("AA83:AA83").Select
Range("AA83:AA83").Activate
Selection.RowHeight = 13.5

Range("os56") = 0
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,230
Messages
5,594,952
Members
413,954
Latest member
mrsandy

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
Top