SowersWebTech
SowersWebTech

Reputation: 21

How to: Sum all cells in Column B IF they are higher than the cells in Column A

I have a workbook with multiple sheets. On one sheet(MainTable) I am trying to display the Sum of all cell values in Column B (on another sheet:DataTable) Only IF the values are higher than the cells in Column A (on the same sheet:dataTable).

Example: Sheet 1: MainTable: I want to display the total sum of cells in Column B (in sheet 2) IF the value is higher than the adjacent cell in Column A (in sheet 2).

Sheet 2: DataTable: 
Column A - Column B
R1: 20, 50
R2: 20, 0
R3: 50, 100
R4: 50, 0
R5: 100, 25

In the above example, there are 2 cells where the value Column B is higher than the value in Column A. I would like to display the sum of these cells on Sheet 1 somewhere (only if they are higher than Column A). It should be noted that the range will not stay the same as more records are added. I created "Tables" of the data so I've been referencing the other tables in my formulas. I've spent 2 days looking online at different search results and can't figure out how to compare the two ranges and only sum the cells in one column when the value is higher than the cells in the other column. I did find formulas to Sum all values if they are greater than the value in one cell but I need to compare the 2 cells in each row before summing and I can't figure it out. Thank you for any help, I tried searching on here before posting so I apologize if there's a posted solution already.

Upvotes: 0

Views: 801

Answers (1)

BigBen
BigBen

Reputation: 50142

Use SUMPRODUCT:

=SUMPRODUCT(B1:B5*(B1:B5>A1:A5))

enter image description here

Upvotes: 0

Related Questions