ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Summing vlookups? (https://www.excelbanter.com/excel-worksheet-functions/8074-summing-vlookups.html)

Patti

Summing vlookups?
 
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!

Frank Kabel

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

--
Regards
Frank Kabel
Frankfurt, Germany
"Patti" schrieb im Newsbeitrag
...
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!




Patti

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" wrote:

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

--
Regards
Frank Kabel
Frankfurt, Germany
"Patti" schrieb im Newsbeitrag
...
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!





Peo Sjoblom

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" wrote:

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" wrote:

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

--
Regards
Frank Kabel
Frankfurt, Germany
"Patti" schrieb im Newsbeitrag
...
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!





Patti

Ah! That did the trick! Thanks so much!

"Peo Sjoblom" wrote:

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" wrote:

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" wrote:

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

--
Regards
Frank Kabel
Frankfurt, Germany
"Patti" schrieb im Newsbeitrag
...
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!





All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com