Auto Opening a dated workbook

N

noah

I have a macro code that at one point opens a monthly workbook to cop
data to. This monthly workbook's name changes every month due to th
month in the file name.
Example :my macro calls,
Workbooks.Open Filename:= _
"C:\Directory\Folder\Monthly-May '04.xls"
Now every month I have to go into the code and change the month in th
filename. I want to find a way to automate this.
Is there a way I can find the current month and define that so that th
macro can find and open the current month workbook
 
F

Frank Kabel

Hi
try the following:

dim fname
fname = "C:\Directory\Folder\Monthly-"
fname=fname & format(date,"MMMM 'YY") & ".xls"
workbooks.open fname
 
N

noah

Thanks Frank!
that is awesome.
Frank said:
*Hi
try the following:

dim fname
fname = "C:\Directory\Folder\Monthly-"
fname=fname & format(date,"MMMM 'YY") & ".xls"
workbooks.open fname
 

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