Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Accessing Excel Sheet


Hello,
When I look under the Excel Objects in the VBA Project window, the
worksheets are listed are listed by sheet number with a name, e.g.,
Sheet1(Sheet1) or Sheet1(Bill) if I have named the first sheet Bill.

How can I select the sheet based on the Sheet1, not the name of the
sheet? Or can I? I want to be able to select the sheet even if the
name is changed by a user.

Thanks,

Bill


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Accessing Excel Sheet

You can always grab the sheet by the index. Sheets(1) But this can be
changed by the user as well.

Charles

Bill wrote:
Hello,
When I look under the Excel Objects in the VBA Project window, the
worksheets are listed are listed by sheet number with a name, e.g.,
Sheet1(Sheet1) or Sheet1(Bill) if I have named the first sheet Bill.

How can I select the sheet based on the Sheet1, not the name of the
sheet? Or can I? I want to be able to select the sheet even if the
name is changed by a user.

Thanks,

Bill


*** Sent via Developersdex http://www.developersdex.com ***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Accessing Excel Sheet

Sheet1.Activate
Sheet2.Activate

The name in parentheses is the text name that appears on the sheet tab.
Worksheets("Bill").Activate

Worksheets(1).Activate will address the first worksheet in the workbook
starting at the left. So, if Sheet15 was the first sheet tab, it would be
Activated.

Mike F

"Die_Another_Day" wrote in message
oups.com...
You can always grab the sheet by the index. Sheets(1) But this can be
changed by the user as well.

Charles

Bill wrote:
Hello,
When I look under the Excel Objects in the VBA Project window, the
worksheets are listed are listed by sheet number with a name, e.g.,
Sheet1(Sheet1) or Sheet1(Bill) if I have named the first sheet Bill.

How can I select the sheet based on the Sheet1, not the name of the
sheet? Or can I? I want to be able to select the sheet even if the
name is changed by a user.

Thanks,

Bill


*** Sent via Developersdex http://www.developersdex.com ***




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Accessing Excel Sheet

The first part is the actual object and the second part the Tab name is just
a property of the object. The long and the short of it is it is a whole lot
easier to refer to the object than it is to refer to the object indirectly by
its tab name property. Try this and notice that intellisence (drop down list)
works when you type it in

Sheet1.Select

You can change the Sheet1 to something more meaningful by editing it in the
properties (View - Properties if the window is not open). The first item is
(Name). When you change this you change the name of the object. So Sheet1 can
become something more meaningful like shtSourceDataSheet
--
HTH...

Jim Thomlinson


"Bill" wrote:


Hello,
When I look under the Excel Objects in the VBA Project window, the
worksheets are listed are listed by sheet number with a name, e.g.,
Sheet1(Sheet1) or Sheet1(Bill) if I have named the first sheet Bill.

How can I select the sheet based on the Sheet1, not the name of the
sheet? Or can I? I want to be able to select the sheet even if the
name is changed by a user.

Thanks,

Bill


*** Sent via Developersdex http://www.developersdex.com ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Accessing Excel Sheet


Thanks a lot.
If I want to know the object of a sheet, it appears I can use:

sheets("Bill").codename

Is that correct?

Bill


*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Accessing Excel Sheet

That will return something like "Sheet1" which is the codename of the sheet
unless you went through the properties and changed the (Name) of the sheet.
Pretty much as soon as I start any new Excel/VBA project I go through and
rename the CodeNames of all of the sheets. I alway prefix the sheet names
with "sht". So when you look through my code it is full of
shtMySheet.Range("A1").???
This makes the code very compact legible and bullet proof...
--
HTH...

Jim Thomlinson


"Bill" wrote:


Thanks a lot.
If I want to know the object of a sheet, it appears I can use:

sheets("Bill").codename

Is that correct?

Bill


*** Sent via Developersdex http://www.developersdex.com ***

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
Accessing Other Sheet Tabs from within Excel Eric Excel Worksheet Functions 4 August 21st 09 06:20 PM
Problem seeing and accessing top of sheet egii Excel Discussion (Misc queries) 1 January 11th 07 02:52 AM
Accessing a non-active sheet from a userform Ken Loomis Excel Programming 2 October 5th 04 06:45 AM
Newbie question about accessing Excel sheet from the web Patrick[_10_] Excel Programming 0 August 10th 04 06:50 PM
Accessing a textbox on a sheet.... Cyril[_2_] Excel Programming 1 August 11th 03 06:37 PM


All times are GMT +1. The time now is 12:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"