FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,368
- Office Version
- 365
- 2016
- Platform
- Windows
I need to save the current workbook with a new name and then run a macro on just the new workbook. I would also like to close the new workbook, but keep the original workbook open.
Here is what I have so far. The new workbook is getting saved with the macro running on the new workbook, but both workbook close. Should I name the current workbook in the code?
The current workbook is Master.xlsm
Here is what I have so far. The new workbook is getting saved with the macro running on the new workbook, but both workbook close. Should I name the current workbook in the code?
The current workbook is Master.xlsm
Code:
Sub Save_it()
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim FilePath As String
FilePath = ActiveWorkbook.Path & Application.PathSeparator
Set Destwb = ActiveWorkbook
With Destwb
.SaveAs FilePath & "Input.xlsm", FileFormat:=52
Call DeleteSheets
.Close SaveChanges:=True
End With
End Sub
Code:
Sub DeleteSheets()
Application.DisplayAlerts = False
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
Application.DisplayAlerts = True
End Sub