Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do i assign the ActiveWorkbook.Worksheets to a worksheets object? | Excel Worksheet Functions | |||
Worksheets() Object | Excel Programming | |||
Adding a sheets name to the worksheets that are copied over from an addin file to the activeworkbook | Excel Programming | |||
For Each wks In ActiveWorkbook.Worksheets bar a specific one? | Excel Discussion (Misc queries) | |||
Populating a listbox will a certain cell on multiple worksheets in the activeworkbook | Excel Programming |