find entire cell value

S

smandula

I can not find the true sum count per row occurence when using values
less than 10
in A1 and B1 such as 3, 16 or when using 1, 2
VBA works fine when A1 and B1 are higher than 10 such as 31, 35 or
even 10,11

Sub GetCount()
Dim No1 As Single
Dim No2 As Single
Dim NumberOfRows As Single
Dim RowRange As Range
Dim Count As Single
Dim Counter As Integer
No1 = [A1]
No2 = [B1]
NumberOfRows = Range("B3", Range("B" & Rows.Count). _
End(xlUp).Address).Rows.Count
Count = 0
Set RowRange = Range("B3", "G3")
For Counter = 1 To NumberOfRows
If Not (RowRange.Find(No1) Is Nothing) = True And _
Not (RowRange.Find(No2) Is Nothing) = True Then _
Count = Count + 1
Set RowRange = RowRange.Offset(1)
Next
MsgBox "Number of occurrences is: " & Count
End Sub
 
D

Doug Glancy

What if your find looks like this:

Find(What := No1,LookAt :=xlWhole)

hth,

Doug
 
S

smandula

Thank's ever so much for the assistance.
Your solution works like a charm.

Thank's again
 

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