determinate if a range is empty

G

GUS

I want find with macro if a range of cells is empty or has at least one
value
(Example: range("A5:c30") )
 
J

Jan Kronsell

Here is one way to do it, if you only need to know if all cells in the
rangfe are empty or at least one cell is not enmpty:

Sub EmptyRange()
For Each c In ActiveWorkbook.ActiveSheet.Range("a5:c30").Cells
If Not IsEmpty(c) Then
MsgBox "At least one cell: " & c.Address & " in the range
contains data", vbonkonly + vbInformation
Exit Sub
End If
Next c
MsgBox "All cells within range are empty", vbOKOnly + vbInformation
End Sub

Jan
 
C

Combo

Save hard processing!


If WorksheetFunction.CountA(Plan1.Range("A5:C30")) = Empty Then

....

End If
 
Top