Avatar of CC10
CC10
 asked on

run macro for selected sheets in workbook

Hello,

the macro below runs for all the sheets in Wb"A".

Can one change it so that it runs for only for the selected sheets with names sheet1, sheet2, sheet6 and sheet10

Thanks,
CC

Sub processAllSheets()

    Dim iSheet As Worksheet

For Each iSheet In Workbooks("A.xlsx").Sheets
     Call CopyRowsByDate(iSheet.Name)
Next iSheet

End Sub
Microsoft OfficeMicrosoft Excel

Avatar of undefined
Last Comment
Joe Howard

8/22/2022 - Mon
Steven Harris

This is the part that is looking at all sheets:

Dim iSheet As Worksheet

For Each iSheet In Workbooks("A.xlsx").Sheets

Open in new window


You would want to do something like:

Sub processAllSheets()

Dim iSheet
iSheet = Array(Sheet1, Sheet2, Sheet6, Sheet10)

For Each iSheet In Workbook
     Call CopyRowsByDate(iSheet.Name)
Next iSheet

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Joe Howard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CC10

ASKER
I was unaware that the A grade was the default and awarded the B grade as I thought it was a relatively simple and uncomplicated question.
If you wish I can change it to an A grade but how do I do that.

CC
Joe Howard

Thank you.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23