Multiple Macro scripts with 1 command button

Jus10fl84

New Member
Joined
May 15, 2018
Messages
1
Greetings,

I'm trying to have two VBA statements run with 1 command button in my excel workbook. is that possible? I'm VERY new to VBA and macro's and I do not have a reference book handy at the moment. any tips would be grateful!



Sub Enable_events()
Application.EnableEvents = True
End Sub


Private Sub CommandButton1_Click()
'Protect worksheet with a password
Sheets("Cover").Protect Password:="SPPF"


End If


Sub Unhide_Multiple_Sheets()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets

ws.Visible = xlSheetVisible

Next ws


End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Welcome to the Board!

I am assuming that you want to run both "Enable_events" and "Unhide_Multiple_Sheets" when you click Command Button 1.
That is pretty easy to do. Just do this:
Code:
[COLOR=#333333]Private Sub CommandButton1_Click()[/COLOR]

     Enable_events
     Unhide_Multiple_Sheets

[COLOR=#333333]End If[/COLOR]
You can also add whatever other code you want to that as well (like your original code). You just want to be sure to put everything in a logicial order so everything processes properly, based on your requirements.
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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