简体   繁体   中英

How do I find the sum of specific cells within a range?

I have two columns: Category and Score. Eg

Category | Score

Math    | 3
Science | 2
Math    | 4
History | 3
Art     | 1
Science | 1
History | 5
Science | 3
Art     | 2

I would like to have a cell that searches for all of the scores for History and sum that up. What would be the appropriate loop, if, and sum functions in Excel for that? Thanks!

You are looking for the SUMIF function.

Try this: =SUMIF(A:A,"History",B:B)

That will search all of column A for "History" and sum all of column B if "History" is found.

Make sure there are no trailing spaces after "History" (such as "History ") else you will want to clean that up or use a wildcard like so =SUMIF(A:A,"History*",B:B)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM