PC Review


Reply
Thread Tools Rate Thread

How can I open on 3rd Sheet Q

 
 
Sean
Guest
Posts: n/a
 
      27th Oct 2007
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

 
Reply With Quote
 
 
 
 
Ian
Guest
Posts: n/a
 
      27th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      27th Oct 2007
No Ian, I insert a new sheet each week, but is always the 3rd sheet
from the left (if that makes sense)


 
Reply With Quote
 
Ian
Guest
Posts: n/a
 
      27th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> No Ian, I insert a new sheet each week, but is always the 3rd sheet
> from the left (if that makes sense)
>
>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      28th Oct 2007
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 With Quote
 
Ian
Guest
Posts: n/a
 
      28th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      28th Oct 2007
> 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" <(E-Mail Removed)> wrote in message
news:7r7Vi.5034$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 With Quote
 
Ian
Guest
Posts: n/a
 
      29th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:7189568D-64BD-47F4-8F9E-(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
> news:7r7Vi.5034$(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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 With Quote
 
Sean
Guest
Posts: n/a
 
      29th Oct 2007
Thanks for your help Ian, will try it tomorrow, but it looks like what
I need



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      30th Oct 2007
Ian, code below worked perfectly, thanks again


Private Sub Workbook_Open()
Application.ScreenUpdating = False

Sheets.Item(3).Activate

Range("A1").Select

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does a Multi-sheet/user file open on sheet two every time? Frustrated in NJ Microsoft Excel Misc 1 22nd Jan 2010 05:46 PM
Excel Sheet Unviewable ~ able to open, but sheet proper all blue Bee Natural Microsoft Excel Programming 1 18th Aug 2008 04:51 PM
why, when i open a work sheet does a blank sheet open as well =?Utf-8?B?Sm9obg==?= Microsoft Excel Misc 2 7th Jul 2007 06:20 PM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Microsoft Excel Programming 0 6th Apr 2006 03:56 AM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi Microsoft Excel Programming 1 2nd May 2004 03:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 PM.