tbowden
tbowden

Reputation: 1058

Adding cells based on another cell

I am trying to write a formula in excel that:

1) Goes through a column (A:A)

2) Finds a specific word (i.e dog)

3) If the word found is equal to the word specified, then take the value in Column B and add it to the other rows where the same condition is true.

In the example below if dog is specified, then all the cells in column B that have the word dog in the column A cell next to it will be added (The answer will therefore be 9)

(A) (B)
dog  1
dog  3
cat  4
lion 5
cat  3
cat  2
dog  5
lion 3

Upvotes: 0

Views: 1137

Answers (1)

BrakNicku
BrakNicku

Reputation: 5991

The formula you are looking for is SUMIF:

=SUMIF(A:A,"dog",B:B)

EDIT: To look for dog after the first 4 characters you can use:

=SUMIF(A:A,"????dog",B:B)

(if you want to skip only 3 characters as the MID("AZ Dog",4,3) suggests, delete one ?)

If you want to find cell ending with dog use:

=SUMIF(A:A,"*dog",B:B)

Starting with dog:

=SUMIF(A:A,"dog*",B:B)

Including dog anywhere:

=SUMIF(A:A,"*dog*",B:B) 

Upvotes: 2

Related Questions