shahzeb123
Board Regular
- Joined
- Jul 29, 2021
- Messages
- 62
- Office Version
- 2016
- Platform
- Windows
Currently, i am using below mentioned code to save file into new workbook after deletion of all macros.
However, in the main sheet there are button which is being saved in the new sheet.
What i want is to delete all the buttons, macros & pivot before saving the sheet.
However, in the main sheet there are button which is being saved in the new sheet.
What i want is to delete all the buttons, macros & pivot before saving the sheet.
VBA Code:
Sub Buttonsave_Click()
Dim Path As String
'Gets the name of the currently visible worksheet
filename = Range("D5") & "-" & Format(Date, "dd-mmm-yy")
'Copys the visible worksheet to a new workbook
ThisWorkbook.ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial Paste:=xlPasteValues
Path = "C:\Users\shakeelshahzeb\Desktop\Discounting\"
'Saves the new Excel file
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsx"
'Closes the newly created workbook so you are still looking at the original workbook
ActiveWorkbook.Close
End Sub