does this help you?
Formula:
Sub SearchParts()
Dim arrParts() As Variant
Range("A7", "B" & Cells(Rows.CountLarge, "B").End(xlDown).Row).Clear
arrParts = FindParts(CStr(Trim(Cells(2, 2))))
Range("A7").Resize(UBound(arrParts, 2), UBound(arrParts)) = _
WorksheetFunction.Transpose(arrParts)
End Sub
Sub SearchParts_P24leclerc()
Dim arrParts() As Variant
Range("A7", "F" & Cells(Rows.CountLarge, "F").End(xlDown).Row).Clear
'Here the letter C used to be B. You set it to the last column in your database
arrParts = FindParts(CStr(Trim(Cells(2, 2))))
Range("A7").Resize(UBound(arrParts, 2), UBound(arrParts)) = _
WorksheetFunction.Transpose(arrParts)
End Sub
Private Function FindParts(PartNumber As String) As Variant
'made by P24leclec
Dim ws As Worksheet
Dim FoundCell As Range
Dim LastCell As Range
Dim rngParts As Range
Dim FirstAddr As String
Dim arrPart() As Variant
Set ws = Worksheets("Data")
Set rngParts = ws.Range("C2:C" & ws.Cells(Rows.CountLarge, "C").End(xlUp).Row)
With rngParts
Set LastCell = .Cells(.Cells.Count)
End With
Set FoundCell = rngParts.Find(What:=PartNumber, After:=LastCell, LookAt:=xlPart)
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
ReDim arrPart(1 To 4, 1 To 1)
'here 3 used to be 2 because there was only 2 columns in database
'you change it to the number of columns in your database
Do Until FoundCell Is Nothing
arrPart(1, UBound(arrPart, 2)) = FoundCell.Offset(0, -2)
arrPart(2, UBound(arrPart, 2)) = FoundCell.Offset(0, -1)
arrPart(3, UBound(arrPart, 2)) = FoundCell.Value
arrPart(4, UBound(arrPart, 2)) = FoundCell.Offset(0, 1)
'Here you add as many line as you need to display all of your database columns.
ReDim Preserve arrPart(1 To 4, 1 To UBound(arrPart, 2) + 1)
'Here too you change the 2 to the number of columns in your database
Set FoundCell = rngParts.FindNext(After:=FoundCell)
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
FindParts = arrPart
End Function
Bookmarks