google-sheetsgoogle-sheets-formula

Vlookup function for criteria contained in a multiple selection drop down list


I am trying to create a way to use vlookup or something similar to select and calculate a total using a drop down box with the ability to select multiple criteria.

I am using the standard vlookup to find one critera

=VLOOKUP(B36,B$19:C$30,2,0)

By adding multiple vlookup together eg..

=VLOOKUP(B37,B$19:C$30,2,0)+VLOOKUP(B38,B$19:C$30,2,0)

I can combine two critera/cells together.

What I want to do is use multiple critera in a multiple selection drop down box to return one value.

Eg.

A...............B

Apples .....1

Pears ......-1

Oranges....1

Drop down displaying....

Apples

Apples

Pears

Oranges

Expected Answer for the above dropdown: 2

I don't know if anyone else at somepoint may find this helpful.

But this formula

=SPLIT(B2,", ",FALSE)

Splits out the dropdown box into multcomponents

So far it's the only way I can come up with to get the information from a multiple drop down box.

I'd still like to use now the split function combined with vlookup if possible to then be able to return a value as per my original post.

enter image description here

Solution

  • You could directly use the split data in VLOOKUP, search argument, if it's inside a ARRAYFORMULA:

    =ARRAYFORMULA(VLOOKUP(SPLIT(B2,", ",FALSE),B$19:C$30,2,0))
    

    To sum within array context, use SUMPRODUCT:

    =SUMPRODUCT(VLOOKUP(SPLIT(B2,", ",FALSE),B$19:C$30,2,0))