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

Pestomania

Active Member
Joined
May 30, 2018
Messages
282
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,213,491
Messages
6,113,963
Members
448,536
Latest member
CantExcel123

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