At the moment, I am searching on one column. But I am stuck on how to search on two or multiple fields to bring up more of a specific result.
I am trying to narrow my search down from 1 to 2 to bring up more specific data. Can anyone help. Thanks in Advance. Appreciate the help!!!!!
<code>[Public CallDetails As Collection
Public Function Find_CallNumbers(NumberToFind As String) As Collection
Dim rng_to_search As Range
Dim rFound As Range
Dim FirstAddress As String
Dim FoundItem As clsCallDetails
Set CallDetails = New Collection
With ThisWorkbook.Worksheets("Database")
Set rng_to_search = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
With rng_to_search
'Look for the first instance.
Set rFound = .Find(what:=NumberToFind, _
after:=.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchDirection:=xlNext)
If Not rFound Is Nothing Then
FirstAddress = rFound.Address
Do
Set FoundItem = New clsCallDetails 'Create a new instance of the class to hold the details.
With FoundItem
.Title = rFound.Offset(, 7) 'CORRECT
.LoggedBy = rFound.Offset(, 2) 'CORRECT .Offset from column A by 1 column, so column B.
.CallNumber = rFound.Offset(, 3) 'CORRECT
.DateField = rFound.Offset(, 4) 'CORRECT
.OwnerField = rFound.Offset(, 6) 'CORRECT
.Description = rFound.Offset(, 8) 'CORRECT
.Solution = rFound.Offset(, 9) 'CORRECT
.URLImage = rFound.Offset(, 10) 'CORRECT
.DateResolved = rFound.Offset(, 5) 'CORRECT
.Reference = rFound.Offset(, 1) 'CORRECT
End With
CallDetails.Add FoundItem 'Add the class instance to our collection.
Set rFound = .FindNext(rFound) 'Look for the next value.
'Continue searching until we reach the top again.
Loop While Not rFound Is Nothing And rFound.Address <> FirstAddress
End If
End With
End Function]</code>
I am trying to narrow my search down from 1 to 2 to bring up more specific data. Can anyone help. Thanks in Advance. Appreciate the help!!!!!
<code>[Public CallDetails As Collection
Public Function Find_CallNumbers(NumberToFind As String) As Collection
Dim rng_to_search As Range
Dim rFound As Range
Dim FirstAddress As String
Dim FoundItem As clsCallDetails
Set CallDetails = New Collection
With ThisWorkbook.Worksheets("Database")
Set rng_to_search = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
With rng_to_search
'Look for the first instance.
Set rFound = .Find(what:=NumberToFind, _
after:=.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchDirection:=xlNext)
If Not rFound Is Nothing Then
FirstAddress = rFound.Address
Do
Set FoundItem = New clsCallDetails 'Create a new instance of the class to hold the details.
With FoundItem
.Title = rFound.Offset(, 7) 'CORRECT
.LoggedBy = rFound.Offset(, 2) 'CORRECT .Offset from column A by 1 column, so column B.
.CallNumber = rFound.Offset(, 3) 'CORRECT
.DateField = rFound.Offset(, 4) 'CORRECT
.OwnerField = rFound.Offset(, 6) 'CORRECT
.Description = rFound.Offset(, 8) 'CORRECT
.Solution = rFound.Offset(, 9) 'CORRECT
.URLImage = rFound.Offset(, 10) 'CORRECT
.DateResolved = rFound.Offset(, 5) 'CORRECT
.Reference = rFound.Offset(, 1) 'CORRECT
End With
CallDetails.Add FoundItem 'Add the class instance to our collection.
Set rFound = .FindNext(rFound) 'Look for the next value.
'Continue searching until we reach the top again.
Loop While Not rFound Is Nothing And rFound.Address <> FirstAddress
End If
End With
End Function]</code>