Userform to search on two column from data range

Sohaib786

New Member
Joined
Mar 30, 2017
Messages
1
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>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top