Thread: Counting Cells
View Single Post
  #2   Report Post  
Gary''s Student
 
Posts: n/a
Default

Enter and run this macro:

Sub Macro1()
Dim r As Range
Dim count As Long
Cells.Select
For Each r In Selection
If r.Value = "end" Then
Exit For
Else
count = count + 1
End If
Next
MsgBox (count)
End Sub
--
Gary''s Student


"dave" wrote:

I need to count the number of cells in a worksheet until it reaches a
specific value.
i.e count the number of cells until it reaches a cell containing the word
'end'