Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is the difference beyween "Sheets" and WorkSheets" in subrout
I have modules that refer to worksheets sometimes as Sheets("sheetname") and
sometimes as Worksheets("sheetname"). Even when they are used in the same routine, I get no error message and the routine works (at least on my machine; the one it was composed on. Others reporting that it is erroring out for them.) Where does Excel do its versioning? I thought since some of the errors indicate it routine is calling the macro from an old version of the document that it may be a versioning issue (although none of my modules shows a past version in the code). Thanks Jack |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is the difference beyween "Sheets" and WorkSheets" in subrout
The sheets collection includes all sheets (worksheets, charts, macrosheets,
dialogsheets). the Worksheets collection only includes worksheets As for referencing a worksheet, there should be no difference Dim sh as Worksheet set sh = Worksheets("Sheet1") set sh = Sheets("Sheet1") should be no different. This isn't true if you have other kinds of sheets in the workbook (besides worksheets) and you are trying to use an index number into the collection - but you don't show that in your example. -- Regards, Tom Ogilvy "Jack_Feeman" wrote in message ... I have modules that refer to worksheets sometimes as Sheets("sheetname") and sometimes as Worksheets("sheetname"). Even when they are used in the same routine, I get no error message and the routine works (at least on my machine; the one it was composed on. Others reporting that it is erroring out for them.) Where does Excel do its versioning? I thought since some of the errors indicate it routine is calling the macro from an old version of the document that it may be a versioning issue (although none of my modules shows a past version in the code). Thanks Jack |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is the difference beyween "Sheets" and WorkSheets" in sub
Thanks for the quick reply, Tom.
Since users are reporting that the routines are calling old versions of the document thus old versions of the macro, I decided to double all the routines. Actually I learned alot from this cleaning exercise. This workbook deleted a worksheet to replaced it with a clean version of the same form from a custom toolbar. The macros would fail everytime I used them after the replacement. It seems that Excel was incrementing the number of the new sheet each time and since my code refered to the sheet as "Sheet1" (the original number of the sheet), the macros failed since the sheet was no longer number 1. I renamed all references to Sheet1 to Sheets("sheetname") and it works fine now. I just thought that there may be a subtle difference in the terms which would become more prominent under certain conditions. Thanks P.S. I went ahead and changed all instances of Sheets to Worksheets just to be consistent. Jack "Tom Ogilvy" wrote: The sheets collection includes all sheets (worksheets, charts, macrosheets, dialogsheets). the Worksheets collection only includes worksheets As for referencing a worksheet, there should be no difference Dim sh as Worksheet set sh = Worksheets("Sheet1") set sh = Sheets("Sheet1") should be no different. This isn't true if you have other kinds of sheets in the workbook (besides worksheets) and you are trying to use an index number into the collection - but you don't show that in your example. -- Regards, Tom Ogilvy "Jack_Feeman" wrote in message ... I have modules that refer to worksheets sometimes as Sheets("sheetname") and sometimes as Worksheets("sheetname"). Even when they are used in the same routine, I get no error message and the routine works (at least on my machine; the one it was composed on. Others reporting that it is erroring out for them.) Where does Excel do its versioning? I thought since some of the errors indicate it routine is calling the macro from an old version of the document that it may be a versioning issue (although none of my modules shows a past version in the code). Thanks Jack |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
Worksheets("Brackets").DropDowns("Game10").Click | Excel Programming |