我有一个基于列的搜索条件,但我必须输入该单元格中的每个单词,但我想搜索该单元格中的单词或几个单词。这可能吗?
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:=xlWhole, _
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(, 5)
.LoggedBy = rFound.Offset(, 1) 'Offset from column A by 1 column, so column B.
.CallNumber = rFound.Offset(, 2)
.DateField = rFound.Offset(, 3)
.OwnerField = rFound.Offset(, 4)
.Description = rFound.Offset(, 6)
.Solution = rFound.Offset(, 7)
.URLImage = rFound.Offset(, 8)
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