[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# Excel 'If Then' or 'When' statement

Posted on 2004-11-09
Medium Priority
700 Views
OK, I'm doing some accounting in an excel spreadsheet where I list out all of my transactions. I then want to sum up the transactions depending on how they are labeled without sorting them or anything like that. Basically I'm wanting to come up with a formula to look at an entire column and determine if a number should be counted or not. Here's an example:

Col. A       Col. B
deposit     50.00
credit       100.00
credit       120.00
misc.        50.00
deposit     200.00
credit       25.00

Then in the totals section I'm wanting to see this:

deposits    250.00
credits      245.00
misc.        50.00

So for the deposits total I'm wanting to add up all of column b if column a says deposit, and the same for credits and misc. Is this possible? I've thought about making hidden columns where the totals show up if column a says a specific thing and then adding up that hidden column but then every time I come up with a new type for column a i'm going to have to create a new hidden column rather than just copy my formula over again.
0
Question by:inetomaha
• 2

LVL 16

Accepted Solution

sebastienm earned 1000 total points
ID: 12540928
Hi,
You can use the SUMIF( ) function to sum on a criterion:

Say the transaction type is in A1:A100 and the amount in B1:B100
-In D1:D3, write the categories exactly the way they are entered in A1:A100 (no trailing 's'):
-In E1, enter the formula: =SUMIF(\$A\$1:\$A\$100,E1,\$B\$1:\$B\$100)
- copy E1 (menu Edit > Copy), select E2:E3, and paste (menu Edit > Paste)

Regards,
Sebastien
0

Author Comment

ID: 12546137
That worked great!!! Thanks Sebastien!

-marshall-
0

LVL 16

Expert Comment

ID: 12547345
Sebastien
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦
###### Suggested Courses
Course of the Month19 days, 11 hours left to enroll