Copy Range of Cell to another workbook with dynamic souce file

Josephoo

New Member
Joined
Dec 7, 2015
Messages
22
Hi

I would like to ask if anyone have an idea of how to copy range of cell from one workbook to another using VBA with a special condition that the source file name is different everyday. example:

Date of event: 03/04/2017
Folder 1 --> Daily Updates 20170403.xls
Folder 2 --> macroEnabledFile.xlsm

I have an idea on how to copy data from workbook to workbook using VBA but what I have problem is "What if the source file name changes everyday?" because someone updated it everyday with a different name like the date attached to it.

Date of event: 04/04/2017
Folder 1 --> Daily Updates 20170404.xls
Folder 2 --> macroEnabledFile.xlsm

How do I write my codes in such a way as to copy the cell range but referring to a dynamic source file? I suppose I can hardcode but that would defeat the purpose. Or maybe I could do smth like NAME_Dynamicdate.xls for the name of the source file. But I have no idea how I can implement it. Would be great if someone can point me in the right direction.

Thanks Much!!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,215,906
Messages
6,127,660
Members
449,395
Latest member
Perdi

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