Substracting from multiple cells

Copper Contributor

Hey guys,

not able to help myself so I'm trying here.

 

I have a large document where I have summarized all the numbers in one column. Now, if there is a YES next to that number, I need the number in the cell where YES is next to it substracted from the summary of all the numbers. If there is a NO next to the cell, then the number should be added as it is to the cell below the summary of all the numbers. I know that I probably wrote it very confusingly, so I am also including an example of how it should look like (although please keep in mind that in the real document there are much more cells with higher values).

 

Thanks in advance for any help :D

 

excel_example.PNG

1 Reply

@lukimraz 

You can use an IF function to check whether the adjacent cell contains “YES” or “NO” and then subtract or add the value accordingly.

For example, if your summary column is column A and the column with “YES” or “NO” is column B, you could use a formula like this in the cell below the summary of all the numbers:

=IF(B2="YES", A2-SUM(A:A), A2+SUM(A:A))

This formula checks if the value in cell B2 is “YES”. If it is, it subtracts the value in cell A2 from the sum of all the numbers in column A.

If the value in cell B2 is not “YES”, it adds the value in cell A2 to the sum of all the numbers in column A.