View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Michl John Michl is offline
external usenet poster
 
Posts: 81
Default Using Counta with a range

Here are two different approaches that work for me.

Approach #1 - cycle through the range and stop when finding first empty
cell
Sub StopAtEmpty()
For Each cell In Range("A1:A8")
If cell.Value = "" Then
MsgBox cell.Address & " is empty"
Exit Sub
End If
Next cell
End Sub

Approach #2 - cycle through the range and report status of each cell
Sub CheckEmpty()
For Each cell In Range("A1:A8")
If cell.Value = "" Then
MsgBox cell.Address & " is empty"
Else
MsgBox cell.Address & " is not empty"
End If
Next cell
End Sub


- John
www.johnmichl.com/exceltips.htm

Michael Whitney wrote:
I am trying to look at a range of cells to determine if the row is empty
within this range. But the code below is only looking at the first cell, not
the selected range.


Do

Empty_Check = Application.CountA(Cells(ActiveCell.Row,
1).Range("B1:N1").Select)
MsgBox (Str(Empty_Check))
ActiveCell.Offset(1, 0).Range("A1").Select

Loop Until Empty_Check = 0