Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default How can I open on 3rd Sheet Q

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default How can I open on 3rd Sheet Q

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default How can I open on 3rd Sheet Q

No Ian, I insert a new sheet each week, but is always the 3rd sheet
from the left (if that makes sense)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default How can I open on 3rd Sheet Q

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default How can I open on 3rd Sheet Q

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default How can I open on 3rd Sheet Q

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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How can I open on 3rd Sheet Q

but this may only be because it is more adaptable. It may also be that the
routine above doesn't work in every instance.


The "Returning The Name Of The First Sheet" will work under any
circumstances, or at least it does in my testing.




"Ian" wrote in message
...
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





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default How can I open on 3rd Sheet Q

Sorry, Chip. I meant it may not work in every instance with an item number
greater than 1, not that I've had any problems.

It just seems odd that you have totally different code for finding a
specific sheet name and assumed that using a variable in place of the
hard-coded 1 in the first sheet name code might, in some instances, cause a
problem.

Ian

"Chip Pearson" wrote in message
...
but this may only be because it is more adaptable. It may also be that
the routine above doesn't work in every instance.


The "Returning The Name Of The First Sheet" will work under any
circumstances, or at least it does in my testing.




"Ian" wrote in message
...
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







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default How can I open on 3rd Sheet Q

Thanks for your help Ian, will try it tomorrow, but it looks like what
I need



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default How can I open on 3rd Sheet Q

Ian, code below worked perfectly, thanks again


Private Sub Workbook_Open()
Application.ScreenUpdating = False

Sheets.Item(3).Activate

Range("A1").Select

End Sub




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default How can I open on 3rd Sheet Q

Glad to help. Thanks for the feedback.

Ian

"Sean" wrote in message
ups.com...
Ian, code below worked perfectly, thanks again


Private Sub Workbook_Open()
Application.ScreenUpdating = False

Sheets.Item(3).Activate

Range("A1").Select

End Sub




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
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Why does a Multi-sheet/user file open on sheet two every time? Frustrated in NJ Excel Discussion (Misc queries) 1 January 22nd 10 05:46 PM
why, when i open a work sheet does a blank sheet open as well John Excel Discussion (Misc queries) 2 July 7th 07 06:20 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


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