ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how to sum multiple matches to a vlookup command (https://www.excelbanter.com/excel-worksheet-functions/188243-how-sum-multiple-matches-vlookup-command.html)

LoganTaylin

how to sum multiple matches to a vlookup command
 
I need to run a vlookup for an exact value in a range and for each match
calculate the total of the cell adjacent.

For example, James appears in this list twice and I want to reach a sum of
his sales listed.

I know I can do a vlookup command, but I'm not sure what to do when there
are multiple matches. Thanks!

Name Sales Name Total Sales
James $120 James
Bob $168 Bob
Randy $65 Randy
James $54 Henry
Henry $796 Pete
Pete $164 Alfred
Bob $638
Alfred $945
Randy $12
Henry $578
Alfred $324
Pete $179


ExcelBanter AI

Answer: how to sum multiple matches to a vlookup command
 
  1. In a new column next to the "Total Sales" column, enter the formula
    Code:

    =SUMIF(A:A,D2,B:B)
    in cell E2 (assuming your data starts in row 2). This formula will sum all the sales in column B where the name in column A matches the name in cell D2.
  2. Copy the formula down to the rest of the cells in column E by selecting cell E2, dragging the fill handle (the small square in the bottom right corner of the cell) down to the last row of your data, and releasing the mouse button.
  3. Now you should have the total sales for each name in the "Total Sales" column.
  4. If you want to make the table dynamic, you can use a named range for the data and adjust the formula to reference the named range instead of the specific column letters. To create a named range, select the data (including headers) and go to Formulas Define Name. Give the range a name (e.g. "SalesData") and click OK. Then adjust the formula to
    Code:

    =SUMIF(SalesData[Name],D2,SalesData[Sales])
    . This will sum all the sales in the "Sales" column where the name in the "Name" column matches the name in cell D2.

Mike H

how to sum multiple matches to a vlookup command
 
Try

=SUMPRODUCT((A2:A13="James")*(B2:B13))

you may also get away with
=SUMPRODUCT(($A$2:$A$13=A2)*($B$2:$B$13))

and drag down.

Mike

"LoganTaylin" wrote:

I need to run a vlookup for an exact value in a range and for each match
calculate the total of the cell adjacent.

For example, James appears in this list twice and I want to reach a sum of
his sales listed.

I know I can do a vlookup command, but I'm not sure what to do when there
are multiple matches. Thanks!

Name Sales Name Total Sales
James $120 James
Bob $168 Bob
Randy $65 Randy
James $54 Henry
Henry $796 Pete
Pete $164 Alfred
Bob $638
Alfred $945
Randy $12
Henry $578
Alfred $324
Pete $179


Max

how to sum multiple matches to a vlookup command
 
You can get by with SUMIF
In E1, copied down: =SUMIF(A:A,D1,B:B)
where the unique names are listed in D1 down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"LoganTaylin" wrote:
I need to run a vlookup for an exact value in a range and for each match
calculate the total of the cell adjacent.

For example, James appears in this list twice and I want to reach a sum of
his sales listed.

I know I can do a vlookup command, but I'm not sure what to do when there
are multiple matches. Thanks!

Name Sales Name Total Sales
James $120 James
Bob $168 Bob
Randy $65 Randy
James $54 Henry
Henry $796 Pete
Pete $164 Alfred
Bob $638
Alfred $945
Randy $12
Henry $578
Alfred $324
Pete $179



All times are GMT +1. The time now is 09:06 PM.

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