Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default find entire cell value

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

Thank's again

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL function;find string in entire column & return cell referenc Audit Compliance Man Excel Worksheet Functions 2 April 21st 23 10:24 AM
Find and Replace formatting formats the ENTIRE cell Duy Nguyen Excel Discussion (Misc queries) 2 April 16th 07 02:28 PM
Use find to select entire rows with a cell with that value Franky88 Excel Worksheet Functions 2 March 30th 07 06:38 PM
find a specific cell from the entire worksheet CINDY Excel Worksheet Functions 1 November 15th 06 05:55 AM
macro to find date format in a cell and delete that entire row vikram Excel Programming 8 April 30th 04 06:00 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"