find a non-empty cell

V

Valeria

Dear experts,
what is the quickest VBA way to determine in a big cells range if at least
one of them is non empty?
Many thanks for your help!
Best regards
 
J

Jacob Skaria

Does this help..


Set varRange = Selection.Find("*")
If Not varRange Is Nothing Then MsgBox "Data exist in this range"
 
M

Mike H

Hi,

This tells you the empty cells in a range and you can modify this easily to
tell you how many cells are not empty


If WorksheetFunction.CountA(Range("A1:c1000")) = _
Range("A1:C1000").Cells.Count Then
MsgBox "No empty cells"
Else
num = Range("A1:C1000").Cells.Count - _
WorksheetFunction.CountA(Range("A1:c1000"))
MsgBox num & " Empty cells in range"
End If
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
R

Rick Rothstein

You didn't have to set the Find call to a variable before testing for data
in the range; this works the same way your code does...

If Not Selection.Find("*") Is Nothing Then MsgBox "Data exist in the range"
 

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