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
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