Auto Save

S

STEVEB

Hi,

Does anyone have any suggestionsfor a Macro that would save the current
workbook with the file name-prior month/year.

For example this month (August) the file would be saved as:

Expenses July 2005.xls

Next month (September)

Expenses August 2005.xls

Thanks for your help!
 
B

bhofsetz

Here is a macro that should do what you want.

Sub SaveAsLastMonth()
Dim LastMonth As String, ThisYear As String
If Month(Date) = 1 Then
LastMonth = "December"
ThisYear = Year(Date) - 1
Else
LastMonth = MonthName(Month(Date) - 1)
ThisYear = Year(Date)
End If
ActiveWorkbook.SaveAs ("Expenses " & LastMonth & " " & ThisYear &
".xls")
End Sub

enjoy
 
S

STEVE BELL

Steve,

Found this interesting function...

filen = "Expenses " & Format(DateAdd("m", -1, Date), "mmmm yyyy")

use filen in your save-as code.
 
S

STEVEB

Thanks bhofsetz & Steve Bell

Both suggestions worked great! I really appreciate your help! It save
me alot of time
 

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