thomas.szwed
12-05-2007, 10:04 AM
Hello again!
I have a query regarding some code to help me find an exact value in sheet. I need to know how to find an exact number from a range of cells as opposed to finding one number character that could be say 8 digits long. For example my current code is -
Private Sub btnSelectRecord_Click()
Dim FirstAddress As String
Dim strFind As String 'what to find
Dim rSearch As Range 'range to search
Dim i As Integer
i = 1
Set rSearch = Sheet1.Range("a2", Range("d65536").End(xlUp))
strFind = Me.txtPersNum.Value 'text box on userform holding the number we are looking for
With rSearch
Set c = Cells.Find(strFind, LookIn:=xlValues)
If Not c Is Nothing Then 'found it
c.Select
ActiveCell.Offset(0, -3).Activate ' used for other process i have spinning of this
i = i + 1
Set c = Cells.FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End Sub
Say for instance the number i am looking for is 8.....it will search the range to find any number with 8 inside it e.g. so it could be 2008. Which is wrong, because i only want it to find the number i am looking for in the case is just 8 on its own.....Is this Cells.Find code or something because i cant get it to work.......appreciate your help
Tom
I have a query regarding some code to help me find an exact value in sheet. I need to know how to find an exact number from a range of cells as opposed to finding one number character that could be say 8 digits long. For example my current code is -
Private Sub btnSelectRecord_Click()
Dim FirstAddress As String
Dim strFind As String 'what to find
Dim rSearch As Range 'range to search
Dim i As Integer
i = 1
Set rSearch = Sheet1.Range("a2", Range("d65536").End(xlUp))
strFind = Me.txtPersNum.Value 'text box on userform holding the number we are looking for
With rSearch
Set c = Cells.Find(strFind, LookIn:=xlValues)
If Not c Is Nothing Then 'found it
c.Select
ActiveCell.Offset(0, -3).Activate ' used for other process i have spinning of this
i = i + 1
Set c = Cells.FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End Sub
Say for instance the number i am looking for is 8.....it will search the range to find any number with 8 inside it e.g. so it could be 2008. Which is wrong, because i only want it to find the number i am looking for in the case is just 8 on its own.....Is this Cells.Find code or something because i cant get it to work.......appreciate your help
Tom