How to Correct an Excel IF and AND Formula for Closed Items
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.

- 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.
Ensure your start date and completion date columns are formatted as Dates or Numbers, not Text, to avoid #VALUE! errors during the calculation.
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.
Click on the cell where you want the calculated duration to appear.
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.
Press Enter to calculate the result, then drag the fill handle down to apply this formula to the rest of the column.

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. Open your dataset: Launch WPS Spreadsheet and open your project or issue tracking workbook.
- 2. Input the formula: Select the duration column and type your =IF(AND(...)) formula into the formula bar.
- 3. Format as a number: Right-click the result cells, select 'Format Cells', and choose 'Number' to display the duration in days.

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.




