an alternative:
Option Explicit
Sub MyFind()
Dim Message As String, _
Title As String, _
Default As String, _
SearchString As String, _
Location As String, _
Report As String, _
Results As Range, _
WS As Worksheet, _
NotFoundCount As Long, _
Ndx As Variant, _
temp As String
Message = "Enter your query!" ' Set prompt.
Title = "What are you looking for?" ' Set title.
Default = "" ' Set default.
temp = "hhhhhhhhhhhhhhh"
Set WS = Sheets("list")
SearchString = Trim(InputBox(Message, Title, Default))
With WS.Range("A1").CurrentRegion
Set Results = .Find(SearchString, _
MatchCase:=False, _
LookAt:=xlPart, _
LookIn:=xlValues)
If Not Results Is Nothing Then
Location = Results.Address(0, 0)
Do
For Each Ndx In Array("B", "A", "H", "I", "J", "K")
RSet temp = .Cells(Results.Row, Ndx).Value
Default = Default & IIf(Default <> "", vbTab, "") & temp
Next Ndx
Report = Report & IIf(Report <> "", vbCrLf, "") & Default
Default = ""
Set Results = .FindNext(Results)
Loop While Not Results Is Nothing And Results.Address(0, 0) <> Location
Else
NotFoundCount = NotFoundCount + 1
End If
End With
If NotFoundCount = ThisWorkbook.Sheets.Count Then
MsgBox Chr(34) & SearchString & Chr(34) & vbCrLf _
& "was not found", vbCritical + vbOKOnly
Else
For Each Ndx In Array("B", "A", "H", "I", "J", "K")
RSet temp = WS.Cells(1, Ndx).Value
Default = Default & IIf(Default <> "", vbTab, "") & temp
Next Ndx
Default = Default & vbCrLf & WorksheetFunction.Rept("¯", Len(Default) + 5 * Ndx) & vbCrLf
Report = Default & Report
MsgBox Report
End If
End Sub
assumes only one listing sheet.
Bookmarks