soteman2005
New Member
- Joined
- Nov 24, 2005
- Messages
- 32
Hi,
I have this script to copy several worksheets to a new workbook and save it. At the moment, it saves it with the date and time in the filename but I would like to change this so it saves the date and a unique number. How would I get it to do this so that the number starts from 1 each day, and resets to 1 again the next day?
Any help would be greatly appreciated.
Thanks
I have this script to copy several worksheets to a new workbook and save it. At the moment, it saves it with the date and time in the filename but I would like to change this so it saves the date and a unique number. How would I get it to do this so that the number starts from 1 each day, and resets to 1 again the next day?
Any help would be greatly appreciated.
Thanks
Code:
Sub Create_Factbase()
Dim FileName As String
Application.ScreenUpdating = False
FileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)
Sheets(Array("A", "B", "C")).Copy
ActiveWorkbook.SaveAs FileName:=FileName + "_" + Format(Date, "dd-mm-yy") + _
"_" + Format(Time, "hh.mm.ss")
Application.ScreenUpdating = True
End Sub