+ Reply to Thread
Results 1 to 6 of 6

Sheet reference in macro

  1. #1
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208

    Question Sheet reference in macro

    Can you refer to a sheet by # (as it displays in the project window) instead of using

    Please Login or Register  to view this content.
    ?

    For example, could I simply say,

    Please Login or Register  to view this content.
    instead?

    Thanks.

    -gshock

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you look in the VB Editor properties window you will see the sheets listed like this

    Sheet1(Sheet1)

    Sheet1 in brackets will change if the sheet tab is renamed, this is the WorkSheet Name.

    Sheet1 outside the brackests cannot be altered except within the VB Editor. This is the sheet's Codename. IOt is usually better to use this in your code in cae anyone changes the tab's name in the workbook.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208

    Question

    Quote Originally Posted by royUK
    If you look in the VB Editor properties window you will see the sheets listed like this

    Sheet1(Sheet1)

    Sheet1 in brackets will change if the sheet tab is renamed, this is the WorkSheet Name.
    Yes, this is exactly what I was referring to.

    Quote Originally Posted by royUK
    IOt is usually better to use this in your code ....
    Not sure what you mean. What is "IOt?" I think I've got the same idea. I want to avoid any circumstances where someone might change the tab name later.


    So are you saying that if I have something like this:
    Please Login or Register  to view this content.
    my code could read like this instead:
    Please Login or Register  to view this content.
    ???

    Thanks,
    -gshock

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Sorry about the typo, this code should work fine.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208
    Quote Originally Posted by royUK
    Sorry about the typo, this code should work fine.

    Please Login or Register  to view this content.
    royUK,

    That's great. Thanks for the tip. I wasn't being picky. I just didn't know if I missed something or not. I thought it might be an abbreviation I wasn't familiar with. Thank you.

    Regards,

    -gshock

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    No problkem, this laptop has a small keyboard so I often catch two keys!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1