PDA

View Full Version : Amending VBA Script



keilah
08-28-2007, 01:39 AM
Hi
is it possible to amend to the following VBA code, so the each time i save the workbook to the following month from the previous months name....
i.e....July07 to Aug 07

the part i need to amend in the code refers to the following line;

RevalComparisonModel.xls - so that this changes as i change the workbook name to the following month from the previous months name.......

Sub ResertDataFields()
Application.ScreenUpdating = False
Workbooks("Monthly Income Report.xls").Activate
Worksheets("Monthly Income Report").Select
Range("A1:N220").Select
Selection.Copy
Workbooks("RevalComparisonModel.xls").Activate
Worksheets("IncomeReport-").Select
Range("A5:N220").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub

Bob Phillips
08-28-2007, 02:04 AM
I don't see the save, but you can build the filename like this



wbName = "RevalComparisonModel " & Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmmyy") & _
" to " & Format(Date, "mmmyy") & ".xls"

keilah
08-28-2007, 02:17 AM
Hi XLD

thanks for the feedback....but i am totally lost on this one......

where would i add the code.....into my origianl VBA......

thanks

Bob Phillips
08-28-2007, 03:13 AM
I don't know, because as I said i cannot see any save code that you refer to.

But, in principle, build the name variable before you need to use it.