This should work fine, try it:
Sub button()
' Get customer workbook...
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.xlsx),*.xlsx"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
On Error Resume Next
Set customerWorkbook = Application.Workbooks.Open(customerFilename, UpdateLinks:=False, ReadOnly:=True)
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets(1)
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
Dim SourceRng As Range
With sourceSheet
Set SourceRng = .Range(.Cells(16, 1), .Cells(55, 9))
End With
Dim i As Integer
For i = 4 To 43
With targetSheet
.Cells(i, 11).Formula = "=VLOOKUP(" & .Cells(i, 2).Address(False, False, external:=True) & "," & SourceRng.Address(external:=True) & ", 9, False)"
End With
Next i
customerWorkbook.Close SaveChanges:=False
End Sub
Bookmarks