+ Reply to Thread
Results 1 to 10 of 10

VLOOKUP & dynamic ranges

  1. #1
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    VLOOKUP & dynamic ranges

    I get a #REF! error with the following formula:

    =VLOOKUP($M2,INDIRECT(TEXT($AZ2,"DDD")&"1"),17,0)

    M2 is a date, so the range will be called "Sun1" when the date is a Sunday. The range "Sun1" 'refers to':

    =INDEX(Sun!$C:$C,1):INDEX(Sun!$CA:$CA,COUNTA(Sun!$A:$A))

    When I type "Sun1" in the named range box, it highlights the correct area on a sheet called "Sun". When I evaluate the VLOOKUP, the range evaluates correctly to "Sun1".

    I'm stumped - any ideas?

    Thanks in advance.
    Last edited by tone640; 07-21-2011 at 06:14 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: VLOOKUP & dynamic ranges

    What is this part below supposed to result in... this is supposed to result in a range cover that will cover at least 17 columns?

    INDIRECT(TEXT($AZ2,"DDD")&"1")
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: VLOOKUP & dynamic ranges

    Quote Originally Posted by NBVC View Post
    What is this part below supposed to result in... this is supposed to result in a range cover that will cover at least 17 columns?

    INDIRECT(TEXT($AZ2,"DDD")&"1")
    This is the equivalent of INDIRECT(Sun1) - or another day of the week - which is a range that covers columns C:CA, and is as many rows as there is data in column A.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: VLOOKUP & dynamic ranges

    So this doesn't work?

    e.g.

    =VLOOKUP($M2,Sun1,17,0)

    if not, then perhaps post a sample workbook

  5. #5
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: VLOOKUP & dynamic ranges

    Quote Originally Posted by NBVC View Post
    So this doesn't work?

    e.g.

    =VLOOKUP($M2,Sun1,17,0)

    if not, then perhaps post a sample workbook
    That is what is confusing - that works fine, the range is defined correctly, and

    =TEXT($AZ2,"DDD")&"1"

    evaluates to "Sun1".

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: VLOOKUP & dynamic ranges

    Maybe then it cannot be done with the INDIRECT reference... if you posted a sample workbook, it would be easier to confirm.

  7. #7
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: VLOOKUP & dynamic ranges

    Sample attached.
    Attached Files Attached Files

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: VLOOKUP & dynamic ranges

    Yeah, I think using the formula in the Named range to reference causes the issue...

    If the range selection is consistent in the daily sheets, then you can use indirect for just getting the month text...

    e.g.

    =VLOOKUP($M2,INDEX(INDIRECT(TEXT(AZ2,"DDD")&"!$C:$C"),1):INDEX(INDIRECT(TEXT(AZ2,"DDD")&"!$CA:$CA"),COUNTA(INDIRECT(TEXT(AZ2,"DDD")&"!$A:$A"))),17,0)

    copied down... The variable is the day in AZ and the ranges will be the same...

    Does that work for you?

  9. #9
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: VLOOKUP & dynamic ranges

    Thanks NBVC, I'll try that or maybe just use a fixed range.

    Any ideas why this won't work?

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: VLOOKUP & dynamic ranges

    It's an Excel fact. You can't indirectly reference a named range with a formula in it.... much the same way as with Data Validation and trying to use dynamic ranges with formulas... see first sentence here.

+ 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