macro to save as a unique name each time

H

Hegler

I have a co-worker wanting to create a macro so that the
end user can click a button to save the Excel file as a
unique name each time. My first thought was to see if
there was a way that when you do file\save as the date and
time can be appended to the file name. Is this possible?
If so, how? If not, does anyone else have any suggestions
as to how to make Excel save the file as a unique name
each time the button is pushed (macro is run)?
 
R

Ron de Bruin

Hi Hegler

Try this

Sub test()
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
ActiveWorkbook.SaveAs "C:\" & ThisWorkbook.Name _
& " " & strdate & ".xls"
End Sub
 
P

Paul B

Hegler, how about something like this

Sub Save_Sheet()
'saves the sheet with My Workbook For and today's date
Dim MyName As String
MyName = "My Workbook For " & Format(Now, "mmm-dd-yyyy") & ".xls"
ActiveWorkbook.SaveAs Filename:=MyName

End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **
 

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