How to look at last modified workbook and copy data to the new Workbook

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
I'm going to try to explain the best I can!

I have an excel open (Workbook1) currently. There are part numbers in Column A.
I need a VBA to go to a folder named "Pipe" on my desktop and open the Last Modified file(Workbook2). Once open the VBA needs to go to the "Workbook1" and create a new worksheet. Once the new sheet is created, I wanted to copy and paste the data from Workbook2 to Workbook1. Once complete, close Workbook2 without saving.

I hope this makes sense. I have tried a few different codes, links below, but unable to get them to work properly.

https://www.exceltip.com/excel-macros-and-vba/vba-to-open-latest-file.html
I am unable to get the MyFile = DIR to work. States argument is invalid but I copied verbatim.

https://www.mrexcel.com/forum/excel...subfolder-vba-excel-2010-a-2.html#post3656440

Any help is greatly appreciated.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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