• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

run a macro on multiple sheets [SOLVED]

Hi there,

I have a work book containing multiple worksheets, including 52 work sheets for each week of the year.

I want to run a macro on about 26 of those worksheets.

Is there a quick way of running the macro rather than going in to each work sheet and running it 26 times!

How do I isolate the sheets I want to run the macro on?

Kevin
 
You can loop though all the sheets in the macro.


To select the sheets you want to use you could put an If statement or a Select in to look for something, i.e. the sheet name could end in the word 'Run' so the code would look for the word 'Run' at the end of the sheet name in all the sheets and if found would preform the desired changes to that sheet
 
So for example

[pre]
Code:
Sub MyMacro()

Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False

For Each ws In Worksheets
If ws.Name Like "*Run" Then

'Your code here

End If

Next ws

Application.ScreenUpdating = True
Application.DisplayAlerts = True

MsgBox "Complete"

End Sub
[/pre]
 
Back
Top