Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Unhide Worksheets | Excel Discussion (Misc queries) | |||
Keep Format After Merging Worksheets Using CopyFromWorksheet Macro | Excel Discussion (Misc queries) | |||
Print order of worksheets | Excel Discussion (Misc queries) | |||
Duplicate Worksheets | Excel Discussion (Misc queries) | |||
Changing a Link Mid-way Across Worksheets | Excel Worksheet Functions |