I have a workbook where at the end of each month it is saved as the next month. For example this month I have 01-Jan SGA.xls next month I will save this as 02-Feb SGA.xls.
I made this macro that will take some of the sheets, copy them into a new workbook, name the new workbook and then copy the values over onto the new sheet. This works fine - this month, in the code it references the 01-Jan.xls file. Next month when I run the macro it will be from the 02-Feb SGA.xls file.
How do I write the code to call the sheets regardless what the file name is?
I would also like to have the new workbook be named "AR 01-Jan SGA.xls" or whatever the month is. Is there a way to do that as well?
Here's the code
I made this macro that will take some of the sheets, copy them into a new workbook, name the new workbook and then copy the values over onto the new sheet. This works fine - this month, in the code it references the 01-Jan.xls file. Next month when I run the macro it will be from the 02-Feb SGA.xls file.
How do I write the code to call the sheets regardless what the file name is?
I would also like to have the new workbook be named "AR 01-Jan SGA.xls" or whatever the month is. Is there a way to do that as well?
Here's the code
Code:
Sub ARsheetCreation()
'
' ARsheetCreation Macro
'
'
Sheets(Array("7210544.T", "7210528.T", "7210521.T", "3410800.T", "8xxxxxx.T", _
"TotalARBilling.T")).Select
Sheets("TotalARBilling.T").Activate
Sheets(Array("7210544.T", "7210528.T", "7210521.T", "3410800.T", "8xxxxxx.T", _
"TotalARBilling.T")).Copy
ActiveWorkbook.SaveAs Filename:="C:\AR SGA.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Windows("01-Jan SGA.xls").Activate
Range("B9:S58").Select
Selection.Copy
Windows("AR SGA.xls").Activate
Range("B9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
ActiveWorkbook.Save
ActiveWindow.Close
End Sub