Summing vlookups?

G

Guest

I'm stuck! Here's what I'm trying to do:

Vlookup($B$1,Named Range,$B$2,False)

This works, but there's more than one match for $B$1 in column A. I want to
sum the values in the column indicated in cell B2 if the data in column A
match the data in cell B1 --

Sumif(A:A,B1,[Column indicated in cell B2])

The problem is that the column with the values to be summed will change, so
a simple Sumif won't work. Thanks!
 
G

Guest

Thanks for the quick reply Frank, but the number in cell B2 is the column for
the Vlookup and it changes. The problem that I had with the simple SumIf is
that the column to sum will change.

Frank Kabel said:
Hi
try something like
=SUMIF('sheet1'!A1:A100,B2,'sheet1'!B1:B100)

--
Regards
Frank Kabel
Frankfurt, Germany
Patti said:
I'm stuck! Here's what I'm trying to do:

Vlookup($B$1,Named Range,$B$2,False)

This works, but there's more than one match for $B$1 in column A. I want
to
sum the values in the column indicated in cell B2 if the data in column A
match the data in cell B1 --

Sumif(A:A,B1,[Column indicated in cell B2])

The problem is that the column with the values to be summed will change,
so
a simple Sumif won't work. Thanks!
 
G

Guest

You can still do it, assume the named range is MyTable, then use

=SUMPRODUCT(--(INDEX(MyTable,,1)=B1),INDEX(MyTable,,B2))

the first 1 in index tells it to find the match in the first column just
like in a vlookup, then B2 tells what column to sum where A is the lookup
value


Regards,

Peo Sjoblom

Patti said:
Thanks for the quick reply Frank, but the number in cell B2 is the column for
the Vlookup and it changes. The problem that I had with the simple SumIf is
that the column to sum will change.

Frank Kabel said:
Hi
try something like
=SUMIF('sheet1'!A1:A100,B2,'sheet1'!B1:B100)

--
Regards
Frank Kabel
Frankfurt, Germany
Patti said:
I'm stuck! Here's what I'm trying to do:

Vlookup($B$1,Named Range,$B$2,False)

This works, but there's more than one match for $B$1 in column A. I want
to
sum the values in the column indicated in cell B2 if the data in column A
match the data in cell B1 --

Sumif(A:A,B1,[Column indicated in cell B2])

The problem is that the column with the values to be summed will change,
so
a simple Sumif won't work. Thanks!
 
G

Guest

Ah! That did the trick! Thanks so much!

Peo Sjoblom said:
You can still do it, assume the named range is MyTable, then use

=SUMPRODUCT(--(INDEX(MyTable,,1)=B1),INDEX(MyTable,,B2))

the first 1 in index tells it to find the match in the first column just
like in a vlookup, then B2 tells what column to sum where A is the lookup
value


Regards,

Peo Sjoblom

Patti said:
Thanks for the quick reply Frank, but the number in cell B2 is the column for
the Vlookup and it changes. The problem that I had with the simple SumIf is
that the column to sum will change.

Frank Kabel said:
Hi
try something like
=SUMIF('sheet1'!A1:A100,B2,'sheet1'!B1:B100)

--
Regards
Frank Kabel
Frankfurt, Germany
I'm stuck! Here's what I'm trying to do:

Vlookup($B$1,Named Range,$B$2,False)

This works, but there's more than one match for $B$1 in column A. I want
to
sum the values in the column indicated in cell B2 if the data in column A
match the data in cell B1 --

Sumif(A:A,B1,[Column indicated in cell B2])

The problem is that the column with the values to be summed will change,
so
a simple Sumif won't work. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top