Cross Reference in Two Files

jarett

Board Regular
Joined
Apr 12, 2021
Messages
165
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am sure this is a routinely run task but I am not sure the correct terminology of the task to search on it. I have have two different files, file "abc" has column A as "UPC" and column "E" as inventory qty. In file "#2" I have column "C" as "UPC", I want to take the column "E" from file "abc" and import it into file "#2" in a new column next to the corresponding "UPC" record. Is this called a look up? Can this task be automated in a macro?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I think the formula you're looking for is index/match. It can be done via formula, or macro/vba.

Here's a link to the vba route: Translate index/match function to vba code
I am looking at the last post with the formula, but don't quite understand how it is looking at two different files, does this only work if it is 2 different sheets and not separate files?

Oh, and I have no experience in VBA, all my previous attempts have been unsuccessful.
 
Upvote 0
In the example in that link:

test = Application.WorksheetFunction.Index(Sheets("Workers List").Range("C3:C13"), Application.WorksheetFunction.Match(1, Sheets("Workers List").Range("D3:D13"), 0), 1)

referencing another file would look something like:

test = Application.WorksheetFunction.Index(Workbooks("book1.xlsx").Sheets("Workers List").Range("C3:C13"), Application.WorksheetFunction.Match(1, Workbooks("book2.xlsx").Sheets("Workers List").Range("D3:D13"), 0), 1)
 
Upvote 0
One thing to note...for this to work for me, I had to have the other workbooks open.
 
Upvote 0
I struggled with your solution so I found another possible way, I can understand this formula better but, it doesn't work. Do you see any issues?

=INDEX([LAPCO_INV.csv]!$A$2:$E$10000,MATCH(C1,[LAPCO_INV.csv]!$A$2:$A$10000,0),2)
 
Upvote 0
The format of the formula looks fine. You may need to convert your lapco file to an excel file rather than csv. I'd give that a try.
 
Upvote 0
I cant figure out why I get this error.
1643386558709.png
 
Upvote 0
I wonder if the cell has some odd format to it. Try copying that formula and paste it into the formula bar in a different cell.
 
Upvote 0
No luck, I have both files open, would it have something to do with the way I am referencing the other file?

1643387122322.png
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,265
Members
449,149
Latest member
mwdbActuary

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