What to do to run macro on sheet1 to sheet10

  • Thread starter Thread starter Harshad
  • Start date Start date
try this

Sub all_sheet()
Dim ws As Workbook
For x = 1 To Worksheets.Count
Sheets(x).Select
'your code........
Next
End Sub
 
How about something like this? This assumes that you want to do something to
every sheet. If you don't, let me know.

Sub Test()
Dim WS As Worksheet
Dim WB As Workbook

For Each WS In WB.Worksheets
Call PerformStuff(WS)
Next WS

End Sub

Sub PerformStuff(WS As Worksheet)

'Put your "stuff" in here

WS.Cells(1, 1).Value = 1

End Sub
 
This will perform on sheets as they are arranged in the workbook. Post YOUR
code for comments along with which 10 sheets you want. Or, do you only have
10 sheets? More detail.

Sub doeachsheet()
For i = 1 To 3
MsgBox Sheets(i).Name
MsgBox Sheets(i).Range("a1")
Next i
End Sub
 
Daer all,

My workbook cointain54 sheets. i don't want to run all the macro to each
sheet.
Some descreption:
Sheet names in ascending order are: Main, Content, Micro, Help, NN1,
NN2,....,NN50.
I have macros name: Main, Content, Micro1, Micro2, Help, NNA, NNB, NNC.
I have solved to run Main, Content, Micro and Help macro by following code.

Sheets("Sheet Name").Activate

But problem is for remaining Three Macro NNA, NNB and NNC.
NNA, NNB and NNC are
What i should put in a code, that runs my all three NN* macro through sheet
NN1 to NN50.
 
A mod on what I gave you on the post to create the sheets

Sub runsheets()
On Error Resume Next
For i = 1 To 3
MsgBox Sheets("NN" & i).Range("a1")
'do your thing here. selections\activations NOT necessary
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top