macro help - for a file whose name changes based on the date

guruman

Board Regular
Joined
Nov 4, 2004
Messages
64
Hi,

For archiving purposes at work we have to save files with the date at the end of them. So today, the two files that I want to include in the macro are FX020205.xls and CCFX020205.xls

Is there anyway that I can have a macro that will be directed to the folder that they will always be in, look for the beginning of the file name (so FX and CCFX) and then put the date into the 020205 format, put them together and look that up?

Any help would be much appreciated.

Thanks.
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
Re: macro help - for a file whose name changes based on the

Sure. The filename is just a string -- add to it to your heart's content. Here's an example I use:
Code:
fName = "C:\Documents and Settings\My Documents\Yield data " & Format(Date, "mmddyyyy") & ".xls"

But you could put a cell reference in there, formula text, anything. Hope that helps!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,721
Messages
5,597,758
Members
414,171
Latest member
12Rev79

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
Top