Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Selecting different Worksheets from a Loop

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Selecting different Worksheets from a Loop

Does this help?

Sub dosheets()
For i = 1 To Worksheets.Count
Sheets(i).Select
MsgBox ActiveSheet.Name
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ironhydroxide" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Selecting different Worksheets from a Loop

Post your code, or try this:
http://www.rondebruin.nl/copy2.htm

You need something like this...
For Each sh In ActiveWorkbook.Worksheets


Next

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ironhydroxide" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Selecting different Worksheets from a Loop

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.

"Don Guillett" wrote:

Does this help?

Sub dosheets()
For i = 1 To Worksheets.Count
Sheets(i).Select
MsgBox ActiveSheet.Name
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ironhydroxide" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
selecting columns and a loop John Excel Programming 0 August 24th 05 06:59 PM
Selecting columns through a loop GreenInIowa Excel Programming 5 July 22nd 05 04:53 PM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"