VBA Lookup Values in Another Workbook

unknownymous

Board Regular
Joined
Sep 19, 2017
Messages
249
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

I have 2 workbooks on my deck namely Project (source file) and Reference (vlookup reference file).

In Project workbook, I need to look for the Value of F in Reference Sheet column B and populate it in G column.

Project Workbook: I was able to populate the data in column G using below codes but I also need to get other values for Column H:J. Also, badly need to adjust the formula based on the last non-blank cell and hardcode the formula.

Value for Column G = Column C in Reference File
Value for Column H = Column D in Reference File
Value for Column I = Column E in Reference File
Value for Column J = Column F in Reference File

-------------------------------------------------------------------------------
Sub ProjectLookUp()
Dim rw As Long, x As Range
Dim extwbk As Workbook, twb As Workbook


Set twb = ThisWorkbook
Set extwbk = Workbooks.Open("C:\Users\unknown\Documents\Reference.xlsx")
Set x = extwbk.Worksheets("Sheet1").Range("B1:I100000")


With twb.Sheets("Final")


For rw = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(rw, 7) = Application.VLookup(.Cells(rw, 6).Value2, x, 2, False)
Next rw


End With


extwbk.Close savechanges:=False
End Sub

-------------------------------------------------------------------------------

Any help will be much appreciated. :)
 
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,527
Messages
6,125,337
Members
449,218
Latest member
Excel Master

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