+ Reply to Thread
Results 1 to 15 of 15

Using a formula within a vlookup array name

  1. #1
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Question Using a formula within a vlookup array name

    Hello,

    I have this so far:
    Please Login or Register  to view this content.
    The LEFT() function grabs two characters of a product number which is used to distinguish the specific tab in the costing spreadsheet. Note the two spaces on either side because each spreadsheet is named with two spaces on either side of the two character spreadsheet; " BR " for example. But I can't even get the function to work. As is, when the cursor is in the LEFT() brackets, the usual summary tip doesn't show up for it (It still shows the vlookup() summary tooltip thing). I finally got it to recognize the left function by removing the quotes:
    Please Login or Register  to view this content.
    But this still gives me an "Invalid External Reference to a Worksheet" error. I can easily replace the &left(F3,2)$ with a specific sheet name and everything works. Any ideas?
    Last edited by madadd; 04-11-2011 at 06:54 PM.

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

    Re: Using a formula within a vlookup array name

    You would need to employ the use of the INDIRECT function:

    =VLOOKUP(F3,INDIRECT("'[2011-03 Costing Spreadsheet.xls] "&left(F3,2)&" '!$1:$65536"),13)

    but this function only works with the source workbook open.

    If you want to work with closed workbooks, you will need to download and install a free addin from here: Morefunc and use INDIREC.EXT instead of INDIRECT.. you will also need to enter the entire path of the workbook..
    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
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    ah, ok. Why is there a need for the indirect() function?

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

    Re: Using a formula within a vlookup array name

    It is the only function that allows you to reference another sheet or workbook "indirectly" like you are trying to do.

    http://support.microsoft.com/kb/151323

  5. #5
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Hmm. So the indirect() function is returning a value, not the path. So thus I'm getting a vlookup that has a lookup array of just 1 number (which happens to be 17.01 and I don't yet know where that is coming from).

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

    Re: Using a formula within a vlookup array name

    The Indirect is just constructing the path based on what you hard coded and what your reference cell shows.

  7. #7
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Ok. So then is there a way to use the Indirect function to return the table array address for use within vlookup?

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

    Re: Using a formula within a vlookup array name

    I am not sure what you mean.

    Can you elaborate?

  9. #9
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Well, so currently the indirect function is returning a number. But when you plug that number into the vlookup, you get
    =VLOOKUP(F3,'some number here',13)
    That doesn't fit so well with the array that the vlookup is asking for. What I'm looking for is variations like these:
    Please Login or Register  to view this content.
    So all that changes is those two letters, referring to the different sheet names, which need to be grabbed off a different cell (ie. left(F3,2)). As you see, for the vlookup formula, there needs to be an array, not just 1 number which the indirect was returning

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

    Re: Using a formula within a vlookup array name

    No that part: INDIRECT("'[2011-03 Costing Spreadsheet.xls] BR '!$1:$65536") should be returning the range '[2011-03 Costing Spreadsheet.xls] BR '!$1:$65536 and it should pull from the 13th column of that range.

    Note that your formulas don't have the 4th (optional) FALSE argument to ensure an exact match.

  11. #11
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Wow, I'm so sorry. For some reason I ALWAYS forget that the lookup value in a vlookup HAS to be in the 1st column of the array. Mine was incidentally in the third... I feel so dumb. Thank you.

    I do have one more question, but I'm not sure if it needs a new thread.

    In my now working, newly edited formula, I would like to add a formula for the column index number. I feel like this would somehow incorporate an hlookup(), but I don't know if or how that would work within a vlookup function, since there needs to be a number returned.
    Please Login or Register  to view this content.
    The array would be the same, where the top row is where I'm searching. And the lookup values are in the G column instead of the F.

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

    Re: Using a formula within a vlookup array name

    It would probably be something like this:

    Please Login or Register  to view this content.
    where G3 contains the Header value in C10:Z10 to look for and determine column index number.

  13. #13
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Ah nice. One last question, I swear. My lookup value for the match() function turns out to not be exactly the same. Whether its a space added with one or the other or extra characters at the end. I tried adding in a wildcard but I can't get it to work.

    ...MATCH(G3"&*&",INDIRECT(....

    Hopefully you get what I'm trying here.

    EDIT: More specifically: ...MATCH(left(G3,2)"&*&",INDIRECT(....

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

    Re: Using a formula within a vlookup array name

    Maybe you mean:

    Please Login or Register  to view this content.
    or based on your last edit:

    Please Login or Register  to view this content.
    Last edited by NBVC; 04-11-2011 at 05:04 PM.

  15. #15
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Using a formula within a vlookup array name

    Sweeet. Regretfully I'm not as knowledgeable as I'd like to be in the use of ampersands :/

    Thank You!

+ 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