Formula Errors

How to Correct an Excel IF and AND Formula for Closed Items

Phi Hung VoPhi Hung Vo Nov 10, 2026 869 views

Question details

The user needs to fix an IF formula that calculates the time taken to close an item, ensuring it correctly handles both open items and blank completion dates.

How to Correct an Excel IF and AND Formula for Closed Items
Product
Excel
Device & OS
not provided
Scenario
Calculating elapsed time for project management or issue tracking tasks where items can be either open or closed.
Observed behavior
The current formula fails to accurately evaluate both the item status and the presence of a completion date simultaneously, leading to incorrect duration calculations.
Before you start

Ensure your start date and completion date columns are formatted as Dates or Numbers, not Text, to avoid #VALUE! errors during the calculation.

Solution 1Recommended

Combine Conditions Using the AND Function

Use the AND function inside your IF statement to check both the item status and the completion date simultaneously.

To correctly calculate the elapsed time, Excel needs to evaluate two conditions at once: whether the item status is 'Closed' and whether the completion date cell is not empty. The AND function allows you to combine these checks seamlessly.

1
Select the target cell

Click on the cell where you want the calculated duration to appear.

2
Enter the IF and AND formula

Type the formula =IF(AND(I68="Closed", M68<>""), M68-Q68, TODAY()-Q68). Adjust the cell references (I68 for status, M68 for completion date, Q68 for start date) to match your actual data layout.

3
Apply to other rows

Press Enter to calculate the result, then drag the fill handle down to apply this formula to the rest of the column.

Combine Conditions Using the AND Function
Formula Logic Explained: If the item is closed and has a completion date, it subtracts the start date from the completion date. Otherwise, it assumes the item is still open and subtracts the start date from today's date.
Powerful Spreadsheet Tool

Calculate Project Durations Easily in WPS Spreadsheet

WPS Spreadsheet fully supports complex logical functions like IF, AND, and OR, allowing you to manage project timelines and calculate durations effortlessly. It is highly compatible with Microsoft Excel formulas.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open your project or issue tracking workbook.
  2. 2. Input the formula: Select the duration column and type your =IF(AND(...)) formula into the formula bar.
  3. 3. Format as a number: Right-click the result cells, select 'Format Cells', and choose 'Number' to display the duration in days.
Fully compatible with Microsoft Excel formulas and .xlsx filesAdvanced logical and date functions for precise calculationsIntuitive interface for building and troubleshooting complex formulasFree to use with comprehensive spreadsheet capabilities
microsoft office alternative - wps office

Frequently Asked Questions

Why does my IF formula return a #VALUE! error?

This usually happens if one of the date cells contains text instead of a valid date value. Check that your start and completion dates are properly formatted as dates and don't contain hidden spaces.

How can I prevent negative numbers if the start date is in the future?

You can wrap your entire calculation in a MAX function to ensure it never goes below zero, like this: =MAX(0, IF(AND(I68="Closed",M68<>""),M68-Q68,TODAY()-Q68)).

Can I use this formula to exclude weekends from the calculation?

To exclude weekends, you need to replace the standard subtraction (M68-Q68) with the NETWORKDAYS(Q68, M68) function, which calculates only the working days between two dates.