Hi d_rose
This Code will work on your Sample File...chances of it working in the Real World are slim.
The Code assumes both Workbooks are in the Same Folder and runs from Sample BOM.
Option Explicit
Sub Match_Vendor()
Dim wb As Workbook, wb1 As Workbook
Dim ws As Worksheet, ws1 As Worksheet
Dim rng As Range, cel As Range
Dim MyPath As String, FindString As String
Dim wasOpen As Boolean
Dim LR As Long
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
MyPath = wb.path & "\"
On Error Resume Next
Set wb1 = Workbooks("Sample Vendor List.xlsx")
On Error GoTo 0
If wb1 Is Nothing Then
Set wb1 = Workbooks.Open(MyPath & "Sample Vendor List.xlsx")
Else
wasOpen = True
End If
Set ws1 = wb1.Sheets("Sheet1")
With ws
LR = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each cel In .Range("F16:F" & LR)
If Not cel.Value = "" Then
FindString = Split(cel.Text, " ")(0)
With ws1.Columns(1)
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
ws.Cells(cel.Row, "G").Value = .Cells(rng.Row, "C").Value
ws.Cells(cel.Row, "H").Value = .Cells(rng.Row, "D").Value
Else
End If
End With
End If
Next cel
End With
End Sub
Bookmarks