ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto Save (https://www.excelbanter.com/excel-programming/336078-auto-save.html)

STEVEB

Auto Save
 

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!


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=391980


bhofsetz[_122_]

Auto Save
 

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


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=391980


STEVE BELL

Auto Save
 
Steve,

Found this interesting function...

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

use filen in your save-as code.

--
steveB

Remove "AYN" from email to respond
"STEVEB" wrote in
message ...

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!


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile:
http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=391980




STEVEB

Auto Save
 

Thanks bhofsetz & Steve Bell

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

--
STEVE
-----------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...nfo&userid=187
View this thread: http://www.excelforum.com/showthread.php?threadid=39198



All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com