Question

I have a problem using VLOOKUP in spreadsheet.

In sheetA i have column A filled with a dropdown menu using datavalidation references on column A from sheetB. Column B from sheetA contains values type of time. The point is to sum() all values from sheetA which have the same category (column A) as in the actual row in sheetB. My formula is in B2 of sheetB and looks as follows:

=sum(vlookup($A2;namedarea;2))

Where 'namedarea' references on sheetA!A2:B6 and looks like:

║  ║A        ║B        ║
╠══╬═════════╬═════════╣
║ 1║Category ║Value    ║
╟──╫─────────╫─────────╢
║ 2║A        ║10:00:00 ║
║ 3║         ║ 5:00:00 ║
║ 4║A        ║10:00:00 ║
║ 5║         ║         ║
║ 6║B        ║12:00:00 ║
╚══╩═════════╩═════════╝

And sheetB looks like:

║  ║A        ║B        ║
╠══╬═════════╬═════════╣
║ 1║Category ║Sum      ║
╟──╫─────────╫─────────╢
║ 2║A        ║20:00:00 ║
║ 3║B        ║#N/A     ║    
║ 4║C        ║#N/A     ║
╚══╩═════════╩═════════╝

For some reason the vlookup for row 2 works, but same formula for row 3 results in error "Value B could not be found". Where is the bug? Thank you guys for your help :)

Was it helpful?

Solution

VLOOKUP only returns one value. If you want to SUM the range with a condition, use SUMIF() function.

In your case, put the following into sheetB!B2 and drag down: =SUMIF(sheetA!A2:A6,$A2,sheetA!B2:B6)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top