ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If statement or Vlookup in a range (https://www.excelbanter.com/excel-discussion-misc-queries/149855-if-statement-vlookup-range.html)

keri

If statement or Vlookup in a range
 
Hi,

I have a range presented like a table;

ID Cost1 Value1 Cost2
Value2 TotalCost TotalValue

1 50 80 60
90 110 170
5 2000 2200 1000
2300 3000 4500
1 20 40 40
60 60 100
3 10 20 10
20 20 40
2 150 180 160
190 310 370

I want to be able to total all of the values in each colum where the
ID is the same.

Eg. for ID 1 I would like to total all Cost1 values (in this case
return 70), and all value1 values (120). However I could have up to
500 different ID's.

I know how to do an if statement on one line - eg.
=if(a1="1",a2,"")

However I would have to do this on every row for every ID. Is there an
easier way?


KG

If statement or Vlookup in a range
 
Sounds to me like a pivot table would give you what you need. Using SumIf
would probably work too but I think the pivot table would be easier to update.

"keri" wrote:

Hi,

I have a range presented like a table;

ID Cost1 Value1 Cost2
Value2 TotalCost TotalValue

1 50 80 60
90 110 170
5 2000 2200 1000
2300 3000 4500
1 20 40 40
60 60 100
3 10 20 10
20 20 40
2 150 180 160
190 310 370

I want to be able to total all of the values in each colum where the
ID is the same.

Eg. for ID 1 I would like to total all Cost1 values (in this case
return 70), and all value1 values (120). However I could have up to
500 different ID's.

I know how to do an if statement on one line - eg.
=if(a1="1",a2,"")

However I would have to do this on every row for every ID. Is there an
easier way?




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

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