Open file with variable date name based on current date

C

Ciprian

Hello,

I have a folder containing different .xls report files with the name format
"YYYY MM text.xls", where YYYY stands for year, MM for month.

I need a macro which, when run from an excel file saved in a different
loacation, based on the current date, e.g. January 7, 2009, will open the
file "2009 01 text.xls".

Thanks for your help,
Ciperian
 
B

Bernie Deitrick

Workbooks.Open "C:\Foldername\" & Format(Now(),"yyyy mm") & " text.xls"

Except it will open 2010 01 text.xls ;-)

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top