Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I open the 3rd sheet when I open a file. I ask it this way as
each week the name of the '3rd sheet' changes and thats why I can't hard code the specific name of the worksheet within worksheet_open Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assuming this is always the same sheet, but renamed, check the identity of
the sheet in the VB editor. The Excel objects are initially identified as Sheet3(Sheet3), but if you rename it the new name appears in brackets eg Sheet3 (newname). If the "permanent" sheet number is always the same you can use Worksheets(3).Activate Ian "Sean" wrote in message oups.com... How can I open the 3rd sheet when I open a file. I ask it this way as each week the name of the '3rd sheet' changes and thats why I can't hard code the specific name of the worksheet within worksheet_open Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No Ian, I insert a new sheet each week, but is always the 3rd sheet
from the left (if that makes sense) |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, it does make sense.
I've done a bit of digging and found that Sheets(3).Select seems to do what you want. Sheets(3).Activate appears to do the same thing, but I don't know what the difference is between them. The names as listed in VB editor are shown as Sheet number (name) where the number is the position of the sheet counting from the left and the name is the name you give the sheet. They are identical in a new workbook. Ian "Sean" wrote in message ups.com... No Ian, I insert a new sheet each week, but is always the 3rd sheet from the left (if that makes sense) |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ian, on mine, the 3rd sheet from left (which I inserted last Monday)
is Sheet47. When I insert a new sheet in the '3rd position' next Monday, I'm assuming this will be named Sheet48 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry Sean. I'm afraid I'm struggling here.
I've just had a look on Chip Pearson's site and suggest is a variation of something I found there (see http://www.cpearson.com/Excel/sheetref.htm) He has a routine under the heading |"Returning The Name Of The First Worksheet In The Workbook" on that page. In it there is a reference to Item(1). Changing this to Item(3) seems to return the name of the 3rd sheet. This you can use in place of hard coding the name. If that doesn't work, further down the same page he has a routine under the heading " Getting The Name Of A Sheet By Position Number". This is a more complex routine, but this may only be because it is more adaptable. It may also be that the routine above doesn't work in every instance. Hope this helps. Ian "Sean" wrote in message ps.com... Ian, on mine, the 3rd sheet from left (which I inserted last Monday) is Sheet47. When I insert a new sheet in the '3rd position' next Monday, I'm assuming this will be named Sheet48 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ON OPEN VBA Code input incorrectly now excel sheet wont open | New Users to Excel | |||
Why does a Multi-sheet/user file open on sheet two every time? | Excel Discussion (Misc queries) | |||
why, when i open a work sheet does a blank sheet open as well | Excel Discussion (Misc queries) | |||
Search open sheets in workbook and insert into open sheet | Excel Discussion (Misc queries) | |||
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet | Excel Programming |