ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Save AS (https://www.excelbanter.com/excel-worksheet-functions/114406-save.html)

MCH

Save AS
 
I have a Macro button which is used every month to do a SAVE AS the problem
is I have to go in the macro every month and change to the current month,
Does any one know of a way to get the macro to change the month.

Andy Wiggins

Save AS
 
Sample saving routines can be found he
http://www.bygsoftware.com/Excel/VBA/saving.htm

From htat page, here's an example of something that might help you:

''
************************************************** *************************
'' Purpose : Create backup at month end
'' Written : 08-Jul-2004 by Andy Wiggins - Byg Software Ltd
''
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lDat_Today As Date
Dim lDat_Tomorrow As Date
Dim lStr_TargetFile As String
lDat_Today = Date

If "Fri" = Format(Date, "ddd") Then
lDat_Tomorrow = Date + 3
Else
lDat_Tomorrow = Date + 1
End If With ThisWorkbook
If Month(lDat_Today) = Month(lDat_Tomorrow) Then
'' Do nothing, we're still in the same month
Else
'' Tomorrow is a new month so make a backup today
.SaveCopyAs ThisWorkbook.Path & "\" & _
Left(ThisWorkbook.Name, _
InStr(1, LCase(ThisWorkbook.Name), ".xls") - 1) & _
" - " & Format(Now, "yyyymmdd") & ".xls"
End If
'' Save the original
.Save
End With
End Sub-- Andy Wiggins FCCAwww.BygSoftware.comExcel, Access and VBA
Consultancy -"MCH" wrote in message
...
I have a Macro button which is used every month to do a SAVE AS the problem
is I have to go in the macro every month and change to the current month,
Does any one know of a way to get the macro to change the month.




Richard Buttrey

Save AS
 
On Fri, 13 Oct 2006 21:39:02 -0700, MCH
wrote:

I have a Macro button which is used every month to do a SAVE AS the problem
is I have to go in the macro every month and change to the current month,
Does any one know of a way to get the macro to change the month.


The technique I usually use in a case like this is to hold the month
number or name in a named range variable, and use this variable within
the macro code which saves the filename.

Typically month numbers or names appear somwhere in data sheets or
reports anyway, so it's usually just a matter of naming the
appropriate cells. Or better still keeping all your variable names,
like month number etc., in once place, and having them refer to
specific cells.

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________


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

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