MACRO: Catching only filled cell data

S

sumit

I want to have a macro to select the cells with only filled data . I
have tried with the dollar sign to select the entire sheet but it does
not work. just give in options

Thankue
 
G

Gary''s Student

Sub nonempty()
Dim rr As Range, r2 As Range, r3 As Range
Dim r4 As Range
Set r2 = ActiveSheet.UsedRange
Set r3 = ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks)
For Each rr In r2
If Intersect(rr, r3) Is Nothing Then
If r4 Is Nothing Then
Set r4 = rr
Else
Set r4 = Union(r4, rr)
End If
End If
Next
r4.Select
End Sub

But it wil not select cells that have only comments in them.
 
Top