Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 __________________________ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cannot save excel files to a folder on a network | Excel Discussion (Misc queries) | |||
macro save a workbook whilst increasing file no | Excel Worksheet Functions | |||
Save as Msg box | Excel Discussion (Misc queries) | |||
Save as Msg box | Excel Discussion (Misc queries) | |||
Save & Save As features in file menu of Excel | Excel Discussion (Misc queries) |