SOLVED

# How to calculate sum of one column based on a vlookup of another column's values?

Occasional Contributor

# How to calculate sum of one column based on a vlookup of another column's values?

Hi, I am trying to find a way to calculate the sum of values in column B based on the value of cells in column A, as in the attached file. So how many of each T-Shirt size are in columns A + B.

I have tried to use B20=SUMIF(A20:A24;(VLOOKUP(A20;A2:B16;2;FALSE);B2:B16)) but this throws an error.

Any suggestions will be welcomed!

2 Replies
best response confirmed by Colin59 (Occasional Contributor)
Solution

# Re: How to calculate sum of one column based on a vlookup of another column's values?

``=SUMIF(\$A\$2:\$A\$16,A20,\$B\$2:\$B\$16)``

An alternative could be SUMPRODUCT.

# Re: How to calculate sum of one column based on a vlookup of another column's values?

This works! Strange things happen when you have two excel files open and you copy from one to the other (cross-references the file that you copy from).

Many thanks