Macro help

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"}]).

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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,225,476
Messages
6,185,199
Members
453,282
Latest member
roger_nz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top