So ws_needed is range object? I assumed it was a string.
If it is range object use it like...
Application.CountA(ws_needed.Rows(1))
I prefer Application.SomeFunction over WorksheetFunction, since when calculation ends up in error, it actually returns Error value rather than throwing code error.
You can test using...
Debug.Print Application.Match(1, Array("A", "B", "C"), 0)
Debug.Print WorksheetFunction.Match(1, Array("A", "B", "C"), 0)
List of Error constants returned via Application.SomeFunction below.
Error_Val Error Value
#NULL! Error 2000
#DIV/0! Error 2007
#VALUE! Error 2015
#REF! Error 2023
#NAME? Error 2029
#NUM! Error 2036
#N/A Error 2042
Bookmarks