Simple code to find the empty cells in a range and cells with number

S

Subodh

I want to find out how many cells in a given range are empty
Also, since my range can only have numbers in them, it should
also check that the non empty cells do not contain text (only
numbers)
Help to do this in the simplest code possible.
 
R

Rick Rothstein

You should be able to make use of these...

NumberOfEmptyCells = WorksheetFunction.CountBlank(Selection)

NumberOfTextCells = WorksheetFunction.CountIf(Selection, "*")

You can substitute and actual range for the Selection range which I used in
my examples; for instance....

NumberOfEmptyCells = WorksheetFunction.CountBlank(Range("A1:H9"))

NumberOfTextCells = WorksheetFunction.CountIf(Range("A1:H9"), "*")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top