Recording macro to save file with name change

J

jmcclain

I have recorded a macro that will make multiple formatting changes to a .csv
file and then save it in a new directory.

The newly created file will have a new file name each day based on the
current date. For example, todays new file is "Outbound 02-22-07" and
tomorrows will be "Outbound 02-23-07" etc.

But when I look in the VBA editor, the code is specific to the file name at
the time the macro was recorded.

Is there a way to have the macro save it with a variable filename as I have
outlined above?

Any help would be appreciated - this is my jump into using macro's.

With Best Regards,


Jon
 
A

Andrew Taylor

replace the line with the hard-coded filename to something like:

ActiveWorkbook.SaveAs "Outbound " & Format (Now, "mm-dd-yy")
 
T

Tom Ogilvy

activeworkbook.SaveAs "C:\Myfolder\Outbound " & format(date,"mm-dd-yy") &
".csv", xlCSV

or to save it as a workbook:

activeworkbook.SaveAs "C:\Myfolder\Outbound " & format(date,"mm-dd-yy") &
".xls", xlWorkbook
 

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