View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Alternate way to refer to sheets???

Using worksheet index numbers is not a good solution, as user can change the
the order of the sheets or insert new sheets.

Worksheets(2) will always refer to the worksheet placed as second Tab.

You can protect the workbook to prevent user from renaming and inserting new
sheets, if user do not need theese options, or you can use the VBA level
sheet names.

In the project explorer you see two sheet names for each sheet. The first is
the VBA level name which do not change if user change the workbook level
name (tab name).

Use the VBA level sheet name like this:

Sheet2.Activate

Hopes this helps.
....
Per

"marcus" skrev i meddelelsen
...
Hi Robert

Each sheet will have a number assigned to it. Sheet1 will be 1
sheet2, is 2 no matter what you call sheet2.

Worksheets(2).Activate

The above will activate the sheet no matter what the name of "Sheet2"
becomes.

Take care

Marcus