Hi,
I am building a macro to open a workbook and import data from that workbook using VLOOKUP.
I am getting a Run-time error '13' Type mismatch
The code uses FileDialog to prompt user to select the file.
Then I have used variables to store the workbook name and sheet name.
I then use those variables to set range variables to plug into the VLOOKUP formula.
The line of code triggering the error is the .formulaR1C1 line.
Any help to figure out what is wrong would be appreciated.
![]()
Set wb = Workbooks(fullpath) Set ws = wb.Sheets(1) lastcolumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column lastrow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row lcOEF = wsOEF.Cells(1, ws.Columns.Count).End(xlToLeft).Column lrOEF = wsOEF.Cells(ws.Rows.Count, 1).End(xlUp).Row Set headerMRP = ws.Range("A1", Cells(1, lastcolumn)) Set tblMRP = ws.Range("A2", Cells(lastrow, lastcolumn)) Set importMRPRange = wsOEF.Range(wsOEF.Cells(6, 121), wsOEF.Cells(lrOEF, 133)) With importMRPRange .FormulaR1C1 = _ "=VLOOKUP(RC1," & tblMRP & ",MATCH(R5C," & headerMRP & ",0),FALSE)" .Value = .Value End With











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks