Count non-numeric values in a worksheet range

I'm exporting some data from Access to Excel.  In Access the data type of several of the columns is Text, but these columns only contain numeric values (no leading zeros).

When I export this data to Excel, it treats the data as text as well, but I would like convert it to a number.  I've found that the Excel Range.TextToColumns method works to convert these values to numbers, so after exporting, I go to the various columns and use that method to convert the data.

Now I'm working on a more generic routine, and I don't want to hard code the column names, I simply want to test the data type of the field.  If it is text, I want to count to see if any of the "values" in that range are non-numeric.  If they are, then I won't do the conversion, but if all of the cells in a range are numeric, then I'll do the conversion.

So, is there a method or function in Excel which will allow me to get a count of the non-numeric cells in a range?
LVL 52
Dale FyeOwner, Developing Solutions LLCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try

Result = Evaluate("COUNTA(A1:A100)-COUNT(A1:A100*1)")

Dale FyeOwner, Developing Solutions LLCAuthor Commented:

I already have a rng object, and when I do:

Evaluate("CountA(rng)") it returns 1, even if the range has hundreds of rows with values.


Evaluate("Count(rng*1)") is returning zero (0) because it is apparently not recognizing these text values as numbers.

I've already got a little function that loops through the cells of the range and counts them, then uses IsNumeric to determine whether the cell is numeric, but was just wondering whether this could be done with a single line.

Rob HensonFinance AnalystCommented:
In Access the data type of several of the columns is Text, but these columns only contain numeric values (no leading zeros).

You have only numeric values. Would it not make sense to therefore change the data type in Access?

Rob H
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!



Res = Evaluate("COUNTA(" & Rng.Address & ")-COUNT(" & Rng.Address & " * 1)")


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCAuthor Commented:

It would yes, but for compatibility between Access and other databases where the data originally came from, I have left it as text (makes it much less complicated to perform joins on those fields).


What is the purpose of the "*1" in your function?
transforms the a numeric value as text to a number in an array formula

Dale FyeOwner, Developing Solutions LLCAuthor Commented:
This seems to have done the trick.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.