+ Reply to Thread
Results 1 to 4 of 4

named ranges in VLOOKUP

  1. #1
    Registered User
    Join Date
    04-29-2009
    Location
    ATL
    MS-Off Ver
    Excel 2003
    Posts
    1

    named ranges in VLOOKUP

    I am having a problem with named ranges in the VLOOKUP function.

    Here's what I am trying to do:

    I have a main sheet (Sheet1) that contains a table. This table is populated from one of the other sheets in the workbook through a VLOOKUP function.

    At first I didn't have named ranges, and used the INDIRECT function to look up (in cell E4) what sheet to look the data up on (for instance: "Sheet3"):

    VLOOKUP($C11, INDIRECT($E$4 & "!$C$5:$H$116"), 2, FALSE)
    I later decided to use named dynamic ranges so I wouldn't have to change the range reference ($C$5:$H$116) in the formula on the main sheet if the table size on Sheet3 changed in the future.

    I created a dynamic named range on Sheet3 (named "Sheet3TestResults"), and changed the formula to:

    VLOOKUP($C11, INDIRECT($E$4 & "TestResults"), 2, FALSE)
    This way (I thought), I'd be able to change the value in E4 (from Sheet3 to Sheet4, etc), and be able to use the same formula to look up the values.

    However, I can't get the formula to work this way. As quoted above, it returns a #REF.

    Suggestions please! Either on getting the formula to work, on for another way to point to dynamic named ranges on other sheets.

    Thanks!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: named ranges in VLOOKUP

    works for me
    Attached Files Attached Files
    Last edited by martindwilson; 04-29-2009 at 07:23 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: named ranges in VLOOKUP

    INDIRECT won't work with Dynamic Named Ranges

    Martin yours works because your Named Ranges are not Dynamic
    (ie they are hardwired ranges)

    You may be able to make the range dynamic within the formula itself (ie not using DNR) but we'd need to see an example.

    Using Martin's file as an example... dispensing with Named Ranges (ie we assume they will be Dynamic and thus won't work), then you could try an approach such as:

    Sheet1!A1: =VLOOKUP(C11,INDIRECT("'"&E4&"'!A1:B"&MATCH(REPT("Z",255),INDIRECT("'"&E4&"'!B:B"))),2,0)
    Last edited by DonkeyOte; 04-30-2009 at 03:27 AM.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: named ranges in VLOOKUP

    ah ah never noticed that ,i am getting old!

+ 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