Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
TS TS is offline
external usenet poster
 
Posts: 3
Default How do i assign the ActiveWorkbook.Worksheets to a worksheets object?

thanks a lot, that worked

"John Coleman" wrote in message
ups.com...
Change
Dim startSheets As Worksheets
to
Dim startSheets As Sheets

Then Set startSheets = ActiveWorkbook.WorkSheets will work.
The subsequent loop will still throw a run time error - but it isn't
needed since the sheets in question are already part of the collection.
You don't need additional code to initialize startSheets. To verify
this you can replace the loop with

For Each sheet In startSheets
MsgBox sheet.Name
Next

and give it a whirl.

The strange truth behind all this seems to be that there isn't any such
thing as a Worksheets object - even though you can declare a variable
to be one!

Hope that helps

-John Coleman

TS wrote:
doing the commented out stuff below doesn't work. i will be adding
worksheets and so i want to have a collection to start with and just use
those thru my code.

Dim startSheets As Worksheets
Dim sheet As Worksheet


'Set startSheets = ActiveWorkbook.Worksheets

'For Each sheet In ActiveWorkbook.Worksheets
' startSheets.Add (sheet)
'Next

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
How do i assign the ActiveWorkbook.Worksheets to a worksheets object? TS Excel Worksheet Functions 2 December 27th 06 02:49 PM
Worksheets() Object dallin Excel Programming 5 August 13th 06 03:06 AM
Adding a sheets name to the worksheets that are copied over from an addin file to the activeworkbook KimberlyC Excel Programming 2 May 7th 05 04:10 AM
For Each wks In ActiveWorkbook.Worksheets bar a specific one? Pank Mehta Excel Discussion (Misc queries) 4 March 30th 05 04:53 PM
Populating a listbox will a certain cell on multiple worksheets in the activeworkbook KimberlyC Excel Programming 2 March 16th 05 12:49 AM


All times are GMT +1. The time now is 02:20 AM.

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"