Google-sheets – How to count numbers in nearby cell with criteria in Google Sheets

google sheets

I am trying to use Google Sheets to count the hours that my staff works every month. So far I have this:

In the left, my staff write their name and the account of hours they have worked that day. What I would like to do is to count the total hours each one of them has worked in the right hours-column. Is this possible? So far I only know that you can count how many times they have worked using countif, but that does not count the account of hours they have worked.

Best Answer

You may want to give the query() function a try. Assuming your data is in the range A1:D, try:

=query(A1:B; "select A, sum(B) where A <>'' group by A"; 1)

Note: depending on your locale you may have to change the semi-colons with comma's..

This is a one formula solution that will update when new rows are added. I hope that helps ?