+ Reply to Thread
Results 1 to 6 of 6

Relative Sheet Reference Syntax

  1. #1
    Registered User
    Join Date
    06-08-2011
    Location
    Canton, OH
    MS-Off Ver
    Excel 2007
    Posts
    10

    Relative Sheet Reference Syntax

    I have a a macro that refers to sheet names. Well, I've since changed the names of these sheets, and my macro that referenced those sheets no longer works.

    I'm having trouble with the syntax on how to relatively reference these worksheets with their index number. Any help would be greatful.

    Here's the code

    Please Login or Register  to view this content.
    where "Sales Rep Dashboard" is the 1st sheet and "Rep Account Detail" is the 2nd sheet.

    Again, any help would be greatly appreciated.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Relative Sheet Reference Syntax

    Hello adoepker,

    You can reference the worksheets by their positional index (the left to right order when viewed) as follows:
    Please Login or Register  to view this content.

    Because these are references are based on the worksheets' physical positions changing the order will cause problems.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-08-2011
    Location
    Canton, OH
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Relative Sheet Reference Syntax

    When i try to reference the sheet numbers in the first line of the code, the array that selects two sheets, i get an error. I'm sure it's just a simple syntax error, but i can't get it to work for me. .

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Relative Sheet Reference Syntax

    This works for me:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    06-08-2011
    Location
    Canton, OH
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Relative Sheet Reference Syntax

    That code works for me too. Thanks!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Relative Sheet Reference Syntax

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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