Selecting different Worksheets from a Loop

  • Thread starter Thread starter ironhydroxide
  • Start date Start date
I

ironhydroxide

I am trying to select worksheets within a Loop function where the worksheet
changes every time. I thought one could use a String in place of the
Worksheets("worksheet name")
But apparently i am wrong because i get a Run-time error '9' Subscript out
of range (which i think means, there is no worksheet with that name)

Thanks for any and all replies

Ironhydroxide
 
Does this help?

Sub dosheets()
For i = 1 To Worksheets.Count
Sheets(i).Select
MsgBox ActiveSheet.Name
Next i
End Sub
 
Thanks. i realized that i was using worksheets and not sheets (i ran into
this same problem not 6 months ago, but then i stopped using excel and didnt
have to program, so i lost it.

Thanks.
 

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