Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel 2024 Excel 2024 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2016

This topic lists the more common causes of the #VALUE! error in the COUNTIF and COUNTIFS functions.

Problem: The formula refers to cells in a closed workbook

COUNTIF/COUNTIFS functions that refer to a cell or a range in a closed workbook will result in a #VALUE! error.

Note: This is a known issue with several other Excel functions such as SUMIF, SUMIFS, COUNTBLANK, to name a few. See SUMIF, COUNTIF and COUNTBLANK functions return #VALUE! error for more information.

Solution: Open the linked workbook indicated in the formula, and press F9 to refresh the formula.

You can also work around this issue by using SUM and IF functions together in an array formula. See SUMIF, COUNTIF and COUNTBLANK functions return #VALUE! error for more information.

Problem: The string is more than 255 characters

Solution: Shorten the string if possible. If you can’t shorten it, use the CONCATENATE function or the ampersand (&) operator to break down the value into multiple strings. For example,

  • =COUNTIF(B2:B12,"long string"&"another long string")

Need more help?

You can always ask an expert in the Excel Tech Community or get support in Communities.

See Also

Correct a #VALUE! error

COUNTIF function

COUNTIFS function

IF function – nested formulas and avoiding pitfalls

See a video on Advanced IF functions

Overview of formulas in Excel

How to avoid broken formulas

Detect errors in formulas

All Excel functions (alphabetical)

All Excel functions (by category)

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.