Closed
nicoleevelyn Posts 1 Registration date Thursday February 23, 2017 Status Member Last seen February 23, 2017 - Feb 23, 2017 at 02:00 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Feb 27, 2017 at 11:11 AM
Hello,

I'm trying to work out a formula so that I can hand off my timesheet to a new manager and have it work correctly. Right not I sum a row of totals ( = SUM(B2:B20) ) and take out any shifts that aren't being worked. What I want is for the sheet to only add the number of hours if there is a name in the adjacent cell. So something like = IF(ISTEXT(C2), SUM(B2:B20)) but I want to treat each cell individually.

So, is there a way to create a loop that iterates through each line and only adds if the cell is blank?

so if

8:00 - 12:00 | 4 | Alicia
8:00 - 12:30 | 4.5 |
9:00 - 1:00 | 4 | Brent
Total hours | 8 |

I'm hoping this makes sense.
Thank you!

## 1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Updated by TrowaD on 27/02/17 at 11:11 AM
Hi Nicoleevelyn,

Give the following formula a try:
=SUMIF(C2:C20,"<>"&"",B2:B20)

When the cell in column C is not empty, the corresponding cell in column B is added to the total.

Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.