+ Reply to Thread
Results 1 to 5 of 5

Create a dynamic reference in a GoTo statement

  1. #1
    Registered User
    Join Date
    01-28-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Create a dynamic reference in a GoTo statement

    How do I get a GoTo statement to use the contents of a cell in the Reference, not the cell itself.

    Example: Cell R8C1 contains a cell address "xy23" . This address is dynamic as it refers to an alphabatized list that changes automatically as data is added. In this case the location of the beginning of all data starting with the letter F.

    How do I get a GoTo reference to use the cell value, not the cell itself.

    In other words, how do I get the statment Application.Goto Reference:="R8c1" to use the value of the cell (xy23) not the cell itself. Such that when the command is executed it will GoTo cell "xy23" (the beginning of the F entries). The reference in the cell changes automatically as data is added and resorted.

    Currently, the only way I have is to manually change the GOTo reference (e.g. xy23) in the macro manually. As there are 26 letters to the alphabet, I would have to change up to 26 GoTo statements everytime a new entry is made in the spreadsheet, depending on where the new entry falls in the alphabet.

    Suggestions?

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Create a dynamic reference in a GoTo statement

    Please Login or Register  to view this content.
    Adjust code per your needs.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

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

    Re: Create a dynamic reference in a GoTo statement

    A little brutal, but all that comes to mind at the moment to use that GOTO command:
    Please Login or Register  to view this content.

    A different technique might be simpler:
    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!)

  4. #4
    Registered User
    Join Date
    01-28-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Create a dynamic reference in a GoTo statement

    Works great. Thanks for the help.

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

    Re: Create a dynamic reference in a GoTo statement

    Which did you end up going with?

    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