How to return a 0 in a blank cell-formula

Occasional Visitor

Hello all,


I have a formula below where I am returning the number of hours (i.e. 12) depending on what's typed in the B column. My question is, if a cell in the B column is blank because the employee is off that day, how do I add to the formula below so it returns a 0 (zero) if the cell is blank?




Thank you all in advance!



2 Replies



This formula seems to be incorrect and return the wrong result.

So, I've rebuilt this formula for you to return the correct result and to take into account if the blank cells.



Also, you can use the SWITCH function as follows which is shorter:





Hope that helps



If don't use predefined shift, however assume they have the same logic in names, that could be

=IFERROR(((MID(B3,SEARCH("-",B3)+1,LEN(B3)-SEARCH("-",B3)-1)&":00")+(MID(B3,SEARCH("-",B3)-1,1)<>RIGHT(B3,1))*0.5-(LEFT(B3,SEARCH("-",B3)-2) &":00"))*24-0.5,0)