Using IF formula for multiple cells

bdr6

New Member
Joined
Mar 30, 2011
Messages
2
Hi Everyone,

I am trying to write a formula to recognize certain data and add the sum of all cells that meet the criteria.

I have a number of different expense groupings such as accommodation, deck, propulsion etc. I would like to make a formula to go through each row and if B=Accommodation then it will add the expense associated with that row to the accommodation total on a new worksheet but if not then it will not add the cell total ($ amount for each category is listed in Column H). Then I can make a line item for each type of expenses in the new workbook with a total that only picks up the cells in that category. I do not want to sort by Column B and then just subtotal and I would like it to automatically recalculate in the new worksheet if I insert a new row into the original worksheet. The formula that I have right now is:

=IF(B2:B203=Accommodation,SUM(H2:H203),0)

but that does not go line by line, just adds to total of all the cells in Column H if any cell in Column B=Accommodation

I can get it to work for a single line with the formula

=IF (B2=Accommodation,H2,0)

Is there a way to do this for all cells from B2-B203 without typing a formula for each row?

Hope that all made sense.

Thanks in advance.

Bonny
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top