You can use an XLOOKUP function instead of VLOOKUP, in which you can tell Excel what to return if there is no match (instead of returning #N/A).
Then, you can just use a COUNTIF function to count the number of that value you told it to return.
See: XLOOKUP function - Microsoft Support
Example 3 in that link shows exactly how to do that (return something other than #N/A for no match).
I think the reason is is that COUNTIF counts what is returned to the cell, either number or text. It's showing the text #N/A, but the underlying value is the error #N/A
So asking if H3="#N/A" would not be equal because the actual value in cell H3 is the error #N/A, not a text string.
You can count #DIV/0! too, but can't check for equal to that directly either.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.