VBA to Insert Column, Lookup to another workbook, return results.

brlattim

New Member
Joined
Jul 17, 2013
Messages
21
I have a process that multiple users need to run daily. I am looking to automate it for them.

Deliverables
The spreadsheet I am pulling data into (and user will have open is located here: G:\PHBIT_Review
File name is: Sample_Printable.xlsx
Tab name would be Printable_Version
The file I am looking to open (or pull data from) is located here: G:\PHBIT_Review
File name is: Printable_Instructions.xlsx.
Tab name would be Printable_Version

I am looking to do the following
1) Insert column on Sample_Printable (1st file above) into column C. There is already data in column C, so insert into C and assume other data shifts right.
2) In cell C2, add a vlookup to Printable_Instructions. The vlookup would be =VLOOKUP(A2,'[Printable_Instructions.xlsx]Printable_Version'!$A:$C,3,FALSE).

Ideally the formula would cascade down to the end of the dataset. Both data sets on either file might fluctuate # of rows so I think my formula accommodates for that.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If it's the same file names and the same formula each time, you could record a macro doing the exact steps you stated above. Then you could change the range to include a last row variable.
VBA Code:
Dim LR as long
LR = Cells(Rows.count, "A").End(xlUp).Row
Then where the cell selection for C2 happens, change that to ("C2:C" & LR)
This will put the formula in the entire range the same way each time.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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