Jemma Atkinson
Well-known Member
- Joined
- Jul 7, 2008
- Messages
- 509
Hi, i have the below code which creates folders if they do not exist and then copies worksheets to a new workbook. I need to adjust this code, i require to resave active workbook as Summary dd-mm-yy and delete all sheets apart from these.
([{"Workings","Test1","Test2"}]).
([{"Workings","Test1","Test2"}]).
Code:
Sub test1()
Dim myName As String, myFolder As String, e
Dim fso As Object, temp As String
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
myFolder = "C:\Users\Jemma\Documents\Jemma\VBA & Excel\" & Year(Date) & "\" & Format$(Date, "mmm") _
& "\Client_Copies"
For Each e In Split(myFolder, "\")
temp = temp & IIf(temp = "", "", "\") & e
If fso.FolderExists(temp) = False Then fso.CreateFolder (temp)
Next
myName = Format$(Date, "mmddyy") & "_Copy" & ThisWorkbook.Name
With Workbooks.Add
ThisWorkbook.Sheets([{"Workings","Test1","Test2"}]).Copy _
before:=.Sheets(1)
.SaveAs myFolder & "\" & myName
End With
Application.ScreenUpdating = True
End Sub