Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default selecting sheets

Hi

I have named 3 sheets. I want to do a "for each" statement
but i am missing something. see below

For Each s In ThisWorkbook.Worksheets(wsPLimagine, wsPLos,
wsPLcurrency)

any ideas

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default selecting sheets

Kevin,

I am not sure what you are trying to do, access the 3 sheets, or name them,
but the for Next loop should look like

For Each s In ThisWorkbook.Worksheets
MsgBox s.Name 'just as an example
Next s

You cannot do a For next on an array of sheet names as you seem to be trying
to do, but only on the whole collection.

You could test within the loop, like so

For Each s In ThisWorkbook.Worksheets
If s.Name = wsPLimagine Or s.Name = wsPLos Or s.Name = wsPLcurrency
Then
' do your stuff
End If
Next s

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kevin" wrote in message
...
Hi

I have named 3 sheets. I want to do a "for each" statement
but i am missing something. see below

For Each s In ThisWorkbook.Worksheets(wsPLimagine, wsPLos,
wsPLcurrency)

any ideas

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default selecting sheets

Bob/Kevin

This works for me.......

Public Sub lookat()
For Each s In ThisWorkbook.Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
MsgBox s.Name 'just as an example
Next s
End Sub

Gord Dibben XL2002

On Thu, 27 Nov 2003 21:34:15 -0000, "Bob Phillips"
wrote:

Kevin,

I am not sure what you are trying to do, access the 3 sheets, or name them,
but the for Next loop should look like

For Each s In ThisWorkbook.Worksheets
MsgBox s.Name 'just as an example
Next s

You cannot do a For next on an array of sheet names as you seem to be trying
to do, but only on the whole collection.

You could test within the loop, like so

For Each s In ThisWorkbook.Worksheets
If s.Name = wsPLimagine Or s.Name = wsPLos Or s.Name = wsPLcurrency
Then
' do your stuff
End If
Next s


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default selecting sheets

Thanks Bob - thats works fine - i was trying to access the
3 sheets
cheers
-----Original Message-----
Kevin,

I am not sure what you are trying to do, access the 3

sheets, or name them,
but the for Next loop should look like

For Each s In ThisWorkbook.Worksheets
MsgBox s.Name 'just as an example
Next s

You cannot do a For next on an array of sheet names as

you seem to be trying
to do, but only on the whole collection.

You could test within the loop, like so

For Each s In ThisWorkbook.Worksheets
If s.Name = wsPLimagine Or s.Name = wsPLos Or

s.Name = wsPLcurrency
Then
' do your stuff
End If
Next s

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kevin" wrote in

message
...
Hi

I have named 3 sheets. I want to do a "for each"

statement
but i am missing something. see below

For Each s In ThisWorkbook.Worksheets(wsPLimagine,

wsPLos,
wsPLcurrency)

any ideas

thanks



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default selecting sheets

Kevin,

Have you also seen Gord's response, it is more aligned to your original
idea?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"KEVIN" wrote in message
...
Thanks Bob - thats works fine - i was trying to access the
3 sheets
cheers
-----Original Message-----
Kevin,

I am not sure what you are trying to do, access the 3

sheets, or name them,
but the for Next loop should look like

For Each s In ThisWorkbook.Worksheets
MsgBox s.Name 'just as an example
Next s

You cannot do a For next on an array of sheet names as

you seem to be trying
to do, but only on the whole collection.

You could test within the loop, like so

For Each s In ThisWorkbook.Worksheets
If s.Name = wsPLimagine Or s.Name = wsPLos Or

s.Name = wsPLcurrency
Then
' do your stuff
End If
Next s

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kevin" wrote in

message
...
Hi

I have named 3 sheets. I want to do a "for each"

statement
but i am missing something. see below

For Each s In ThisWorkbook.Worksheets(wsPLimagine,

wsPLos,
wsPLcurrency)

any ideas

thanks



.



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
Selecting / UnSelecting sheets shuvro_basu Excel Discussion (Misc queries) 1 August 22nd 05 02:09 PM
Selecting sheets - II Dr.Schwartz Excel Discussion (Misc queries) 4 July 25th 05 02:31 PM
Selecting sheets Dr.Schwartz Excel Discussion (Misc queries) 4 July 14th 05 01:49 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM
selecting sheets jacqui[_2_] Excel Programming 0 September 11th 03 02:46 PM


All times are GMT +1. The time now is 10:44 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"