+ Reply to Thread
Results 1 to 6 of 6

Using Vlookup to lookup array, return array

  1. #1
    Registered User
    Join Date
    11-16-2007
    Posts
    3

    Using Vlookup to lookup array, return array

    Hi,

    I am trying to use vlookup to lookup an array of inputs, and then return an array of outputs. Then, I want to average over these outputs. I'd like to do all of this in one function call. Is it possible to do this, or to do something similar to achieve the same result?

    I am trying to do it, and it's not working.

    This is what my formula says:

    {=AVERAGE(VLOOKUP(B9:B10,B4:C6,2,0))}

    cells B4:C6 contain the an array that looks like this:

    a 1
    b 2
    c 3

    Cells B9:B10 are as follows:

    a
    b

    Thus, I want the vlookup to return the array {1,2}, average over those, and give 1.5. Instead, it returns 1.

    My spreadsheet is enclosed. As you can see, B13 returns 1 instead of 1.5.

    Thanks,
    Jonathan
    Attached Files Attached Files

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If your list in B4:B6 is in ascending order and there will always be exact matches, then try:

    =AVERAGE(LOOKUP(B9:B10,B4:C6))

    confirmed with CTRL+SHIFT+ENTER

    or... if that's not the case... you can try:

    =AVERAGE(IF(ISNUMBER(MATCH(B4:B6,B9:B10,0)),C4:C6))

    also confirmed with CTRL+SHIFT+ENTER
    Last edited by NBVC; 11-16-2007 at 12:51 PM.
    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
    11-16-2007
    Posts
    3
    NBVC,

    Great, thanks, that works!

    Is there any rhyme or reason to which functions can be used to generate intermediate array outputs, and which cannot (e.g. vlookup cannot, lookup can)?

    Jonathan

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Using Vlookup to lookup array, return array

    Try this regular formula:
    Please Login or Register  to view this content.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

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

    Great, thanks, that works!

    Is there any rhyme or reason to which functions can be used to generate intermediate array outputs, and which cannot (e.g. vlookup cannot, lookup can)?

    Jonathan
    I'm not entirely sure, but... I think it just depends on the design of the function and how much detail went over each design by Microsoft (some work in array formulas and some don't)... I tend to just try different functions and go by trial and error...

  6. #6
    Registered User
    Join Date
    11-16-2007
    Posts
    3
    Yes, that also works. Thanks!

+ 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