i200yrs
New Member
- Joined
- Dec 18, 2019
- Messages
- 43
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
Hello All...need some advice...I have a main.xlsm file with sheet2. I want to create a button that when i click it will save the sheet2 into separate workbook.
I found the code below is useful, but when sheet2 is open and i click the button, it got error. Please help how to resolve.
I want something message alert pop-out instead of error...thanks in advance.
I found the code below is useful, but when sheet2 is open and i click the button, it got error. Please help how to resolve.
I want something message alert pop-out instead of error...thanks in advance.
VBA Code:
Sub sb_Copy_Save_Worksheet_As_Workbook()
Dim wb As Workbook
Set wb = Workbooks.Add
ThisWorkbook.Sheets("Sheet2").Copy Before:=wb.Sheets(1)
wb.SaveAs "C:\Users\Desktop\1_Excel\VBA\SheetCopySave\Sheet2.xlsx"
wb.Close
End Sub
Last edited: