count in-between values

V

vinu

Hi,

I want to count the cells in a column that was in-between the
particular values..

i.e. I want the count of cells between cells that contains "Name".

In each sheet the "Name" will come min 10 time to max 30.

Pls Help.

Thanks in advance

Vinod
 
D

Don Guillett

Try this. Change sheet name & mc=4 to suit your column number
'=========
Option Explicit
Public myrow
Sub findnexttext()
Dim myrow As Long
Dim c As Range
Dim mc As Long
Dim firstaddress ' As Range
myrow = 0
mc = 4 'col D
With Worksheets(3).Columns(mc)
Set c = .Find(What:="Name", After:=Cells(1, mc), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not c Is Nothing Then
firstaddress = c.Address
Do
' MsgBox c.Row
MsgBox c.Row - myrow
myrow = c.Row
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top