run on all sheets

sl1990

New Member
Joined
Jun 3, 2011
Messages
20
in the same way you can use

call macro_1
call macro_2
call macro_3

to run macros in order on a sheet is there a similar way to say

run macro_1 on all sheets ?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Maybe this:

Code:
Sub Macro_1
 
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
 
///  Your Macro_1 code here ///

    Next ws
 
End Sub
 
Upvote 0
If I could, would like to add to the solution already offered.

Notice after the For Each statement, the action is prefaced by ws. If this was not the case the procedure to unprotect would not happen on all sheets.

Code:
Sub ProtectIt()
    Dim ws As Worksheet
    For Each ws In Worksheets
        [COLOR="Red"]ws.[/COLOR]Unprotect "password"
    Next ws
End Sub
 
Upvote 0
Jeff,
Did I miss something about the OP's sheets being protected?

I looked at the OP's history of posts, and it seems his posts all relate to his project at hand. But I didn't see anything about Protected Sheets.

Just curious if that was a "fail safe" just in case.
 
Upvote 0
Hi Nalani,

No you did not miss anything, I just showed and example just to illustrate when applying a macro to all spreadsheets you need to use the variable.

I've been caught by this many a time.
 
Upvote 0
I've been caught by this many a time.

Me too.....That and the blasted . period .....

It probably would help to see the OP's 3 Macros - might not need all three??
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,256
Members
452,901
Latest member
LisaGo

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