View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bassman62 Bassman62 is offline
external usenet poster
 
Posts: 117
Default Reference sheet by number or name

Jim,

I think I've got it. I was trying to refer to it as a Worksheet or Sheet but
it looks like I can simply refer to it as I would a variable.
Thank you very much.

Dave


"Jim Thomlinson" wrote:

There are 3 ways to refer to a sheet; by index number, by tab name or by code
name.

Index number is inherantly dangerous as the index of the sheet chan change
based on things that your end user can do such as deleting existing sheets.

Tab name is inherantly dangerous as your code will crash if the user changes
the name of the sheet.

Code name is darn near fool proof. There is nothing that the average and
user can do to change the code name. Additionally the code name refers
directly to the object so your code is shorter and easier to write.

--
HTH...

Jim Thomlinson


"Bassman62" wrote:

In Excel2007;
In past threads I've read conflicting comments re. referencing sheets by
number or code name.
In VBA, how can I refer to the same sheet every time regardless of the
sheets code name or position?
Note the name or position may change often.
Thanks.

Dave