How to Fix COUNTIF #VALUE! Error with Linked OneDrive Workbooks in Excel
Question details
The user needs to resolve a #VALUE! error that occurs when using the COUNTIF function to reference a linked external workbook stored in OneDrive or Microsoft Teams.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Using the COUNTIF function to pull and count data from an external Excel workbook hosted on OneDrive or accessed via Microsoft Teams.
- Observed behavior
- The COUNTIF formula returns a #VALUE! error when the referenced external workbook is closed, even though VLOOKUP and direct cell links continue to function correctly.
Before troubleshooting, ensure you have an active internet connection and sufficient permissions to open the linked external files stored on OneDrive or Microsoft Teams.
Keep the Linked External Workbook Open
The most straightforward solution is to ensure the source workbook remains open in the background while you are working.
The COUNTIF function has a known limitation in Microsoft Excel: it inherently requires access to the active memory of the referenced workbook. When the external file is closed, Excel cannot process the array criteria, causing it to return a #VALUE! error.
Navigate to your OneDrive or Microsoft Teams folder and open the source workbook that your COUNTIF formula is referencing.
Return to your main working file. The #VALUE! error should automatically resolve into the correct count. If it doesn't, press the F9 key on your keyboard to force a manual recalculation.
Replace COUNTIF with the SUMPRODUCT Function
You can replace the COUNTIF function with a SUMPRODUCT formula, which is fully capable of calculating data from closed external workbooks.
Import Data Using Power Query
Importing the source data directly into your current workbook via Power Query completely eliminates external reference errors.
Try WPS Office for a Seamless Spreadsheet Experience
If you are tired of dealing with strict Microsoft Excel limitations like the COUNTIF closed-workbook #VALUE! error, consider switching to WPS Office. It provides a lightweight, highly compatible, and completely free alternative for managing your spreadsheets and cross-sheet references without the hassle.
- 1. Download and Install: Visit the official WPS website to download and install WPS Office for free on your PC or Mac.
- 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing Excel files directly without losing any formatting or data.
- 3. Calculate with Ease: Use built-in formulas and manage cross-sheet references smoothly within a unified workspace.

Frequently Asked Questions
Why does COUNTIF return a #VALUE! error for closed workbooks?
The COUNTIF function, along with COUNTIFS, SUMIF, and SUMIFS, is designed by Microsoft to require the referenced external workbook to remain open in the background. If the source workbook is closed, Excel cannot retrieve the necessary array data to perform the count, resulting in a #VALUE! error.
Does this #VALUE! error happen with local files as well as OneDrive files?
Yes. This is a general architectural limitation of the COUNTIF function when referencing any closed external file. It occurs whether the files are stored locally on your hard drive, synced on OneDrive, or accessed via Microsoft Teams.
Are there other Excel functions that suffer from this closed workbook limitation?
Yes. Besides COUNTIF and COUNTIFS, functions like SUMIF, SUMIFS, COUNTBLANK, and INDIRECT also return a #VALUE! or #REF! error when they reference a closed external workbook. Functions like VLOOKUP, XLOOKUP, and INDEX/MATCH generally continue to work fine.




