Formula Errors

How to Use Nested IF and SUM Formulas for Weekly Hours in Excel

Emma BrownEmma Brown Oct 26, 2026 869 views

Question details

The user needs an Excel formula to total weekly hours across a row, display a blank cell if the total is zero, and drag the formula down to apply it to multiple rows.

How to Use Nested IF and SUM Formulas for Weekly Hours in Excel
Product
Excel
Device & OS
not provided
Scenario
Calculating total weekly hours worked from a timesheet range (e.g., B9:F9) and dynamically copying the calculation to subsequent rows.
Observed behavior
The user wants the calculation to return a completely blank cell instead of displaying a '0' when no hours are logged for the week.
Before you start

Ensure your weekly hours data is entered as numerical values and check that your target cells have enough space to drag down the formula.

Solution 1Recommended

Combine IF and SUM Functions to Calculate and Format Weekly Hours

Use a nested IF and SUM formula to calculate your total hours while automatically hiding any zero values to keep your spreadsheet looking clean.

By default, the SUM function will return a 0 if the referenced cells are empty. Wrapping the SUM function inside an IF statement allows you to test whether the total is zero. If the total is zero, the formula returns an empty string (a blank cell); otherwise, it displays the actual sum.

1
Select the target cell

Click on cell B17, where you want the total weekly hours for the first row to be displayed.

2
Enter the nested formula

Type =IF(SUM(B9:F9)=0,"",SUM(B9:F9)) into the formula bar at the top, then press Enter. This tells Excel to check the sum of B9 through F9. If the result is exactly 0, it leaves the cell blank.

3
Copy the formula down

Click back onto cell B17. Hover your cursor over the small green square in the bottom-right corner of the cell until it turns into a plus sign (the fill handle). Click and drag down through cells B18 to B20 to copy the formula.

Formula Successfully Applied: Your cells will now calculate totals correctly and will remain completely blank if no hours were logged for that specific row.
Effortless Spreadsheet Management

Easily Calculate Timesheets and Formulas with WPS Spreadsheet

WPS Spreadsheet fully supports advanced functions like nested IF and SUM formulas. You can seamlessly calculate hours, manage timesheets, and clean up your data using a familiar, highly compatible interface.

  1. 1. Open your Timesheet in WPS: Launch WPS Office, select Spreadsheet, and open your existing timesheet document.
  2. 2. Apply the Formula: Select your total cell (e.g., B17) and input the formula: =IF(SUM(B9:F9)=0,"",SUM(B9:F9)).
  3. 3. Drag to Autofill: Click the fill handle on the bottom right of the cell and drag it down to automatically calculate the rest of the rows.
Fully compatible with Microsoft Excel (.xlsx) files and advanced formulas.Built-in templates for timesheets, weekly hour tracking, and payroll.Lightweight and runs smoothly on Windows, Mac, and Linux systems.Free to use with an intuitive, familiar user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my SUM formula display a zero instead of being empty?

The SUM function automatically returns a '0' when adding empty cells or calculating values that sum up to zero. Wrapping your SUM in an IF statement forces the cell to display a blank text string ("") instead of the numerical zero.

Can I use formatting instead of a formula to hide zero values in Excel?

Yes. Instead of changing your formula, you can go to Excel Options > Advanced, and uncheck 'Show a zero in cells that have zero value'. Alternatively, you can apply a custom number format like '0;-0;;@' to specifically hide zeros in highlighted cells.

How do I ensure time formats correctly calculate over 24 hours?

If you are using time formats (like 8:30) instead of decimal numbers, Excel might reset the count after 24 hours. To fix this, right-click the total cell, select Format Cells, choose Custom, and type [h]:mm to properly display cumulative hours.