Link to home
Start Free TrialLog in
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
Avatar of Steven Harris
Steven Harris
Flag of United States of America image

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
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CC10
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
Thank you.