Hi there,
I need VBA that will save a file as a customers name (say XYZ Pty Ltd) and the month/year (mm yy). There is a date in cell E2 that I use as a reference.
Can anyone help please?
Thank you.
Hi there,
I need VBA that will save a file as a customers name (say XYZ Pty Ltd) and the month/year (mm yy). There is a date in cell E2 that I use as a reference.
Can anyone help please?
Thank you.
Try
ActiveWorkbook.SaveAs "companty here" & Format(Month(Cells(2, 2).Value) _ & Day(Cells(2, 2).Value), "mm yy")
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Hi Roy,
I tried this code but it causes an error. Seems it wants to finish after "company here" and not add - & Format etc.
Can you help me please?
Thank you.
You will need to add the path to save to.
I've amended the code
ActiveWorkbook.SaveAs "company here" & Format(Cells(2, 2).Value, "mm yy") & ".xls"
Last edited by royUK; 10-31-2008 at 04:44 AM.
Hi Roy,
Thank you for your reply.
I have tried the code and added on the pathway where I want the file saved but I must be doing something incorrectly - keep getting error messages.
The pathway is H:/XYZ Ltd Folder.
Could you please guide me from here?
Thank you.
PS. The date I referred to in Cell E2 is always last months date. So in November I will do a report on October transactions so the file needs to be named XYZ Ltd Oct 08.xls.
Thanks again.
Try this
Sub backUp() Const sPath As String = "H:/XYZ Ltd Folder" Const sCo As String = "XYZ Ltd" ActiveWorkbook.SaveAs sPath & Application.PathSeparator & sCo & "_" & _ Format(Cells(2, 5).Value, "mm yy") & ".xls" End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks