Vlookup From another workbook

Sunil7598

New Member
Joined
Dec 28, 2022
Messages
20
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I just need a code for vlookup from another workbook, I tried a lot but's not working properly. I even tried to recorded macro but workbook name changes everytime.

Actual requirement is Lookup value is in P column of Loan contract & lookup range SFDC_report.Sheets("SFDC Data").Range("B2:AC" & lr).
Lookup should start from Col AO to BI & lr and Col Index Num is 4 to 28 of sfdc report

Set Loan_contract = ActiveWorkbook
Set SFDC_report = Workbooks.Open("X:\WK13\ES_SFDC_data_03_05_2023.xlsx")
Dim rng As Range, lr1 As Long, lcol, lcol1 As Long, lr As Long
Dim i, j, k As Long
lr1 = Loan_contract.Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
lcol1 = Loan_contract.Sheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column

lr = SFDC_report.Sheets("SFDC Data").Cells(Rows.Count, "B").End(xlUp).Row
lcol = SFDC_report.Sheets("SFDC Data").Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = SFDC_report.Sheets("SFDC Data").Range("B2:AC18079")

Loan_contract.Sheets("Data").Activate
k = 4

For j = 41 To lcol1

For i = 2 To lr1

Dim lookupvalue As String
lookupvalue = Loan_contract.Sheets("Data").Cells(i, 16).Value

Loan_contract.Sheets("Data").Cells(i, j).Value = Application.IfError(Application.WorksheetFunction.VLookup(lookupvalue, rng, k, False), "#NA")

Next i
k = k + 1
Next j

thank you for your fast reply. Let me know if need any additional information
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top