Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Worksheets("Brackets").DropDowns("Game10").Click Tony_VBACoder Excel Programming 5 January 28th 05 04:41 AM


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