VBA to vlookup into various xls files in a given folder

Celticfc

Board Regular
Joined
Feb 28, 2016
Messages
153
Hello MR Excel, I've been away for years, nice to be back, really struggling with a problem that I thought would be simple, looked into web/ AI bots but can't figure out:


I have transaction data saved in over 100+ xls files in "Orders" folder on my desktop. There's only 2 columns in these files:

Column A: Order ID
Column B: Total Cost.

All I want is to create a simple Excel file, where I will enter the Order ID in A1 and get the Total Cost into B1. Many thanks in advance.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Not sure why you think this would be simple - they are no function set to look at all files in a folder!

If it were me, I would probably try to approach it one of two ways:

1. Combine all your files into one master file, pasting all the data from your files down the two columns on one page (either manually or via VBA).
Then you would be able to use a simple SUMIF function on any Order ID to get your total cost.

2. Create VBA code that opens all your files in your folder, one-by-one, and gets the total cost of your desired Order ID with a SUMIF function and adds it to a running total.
Then at the end return that running total.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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