Thread: empty range
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default empty range

If application.counta(r) 0 then
msgbox "at least one cell is non-empty"
else
msgbox "all empty"
end if



ranswert wrote:

How do I write a procedure to look at a range of cells, and if all the cells
are empty do one thing, or if at least on cell in the range has something in
it do something else?

I tried

Sub a()
Dim r As Range
Set r = Range("rng")
r.Select
If r is empty Then
MsgBox ("nothing")
Else
MsgBox ("something")
End If
End Sub

That doesn't seem to work.
Thanks


--

Dave Peterson