find entire cell value
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 |
find entire cell value
What if your find looks like this:
Find(What := No1,LookAt :=xlWhole) hth, Doug "smandula" wrote in message oups.com... 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 |
find entire cell value
Thank's ever so much for the assistance.
Your solution works like a charm. Thank's again |
All times are GMT +1. The time now is 06:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com