SquareJerBear
New Member
- Joined
- Jan 27, 2020
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hello, I have played with this and still can't figure it out.
I have connected this macro to a check box:
I need it to add the worksheet with the name being the same as the template. Currently it just populates as "Sheet1 (2)," where I would want the sheet named "5b108a."
Also, is there a way for it to add the sheet, and not switch to the added sheet each time it's clicked?
Thanks.
I have connected this macro to a check box:
VBA Code:
Sub copy_Sheet()
Dim wb As Workbook
Dim activeWB As Workbook
Dim FilePath As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set activeWB = Application.ActiveWorkbook
FilePath = "C:\Users\User\Desktop\Excel\5b108a"
On Error Resume Next
Set wb = Application.Workbooks.Open(FilePath)
wb.Worksheets(1).Copy After:=activeWB.Sheets(activeWB.Sheets.Count)
activeWB.Activate
wb.Close False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I need it to add the worksheet with the name being the same as the template. Currently it just populates as "Sheet1 (2)," where I would want the sheet named "5b108a."
Also, is there a way for it to add the sheet, and not switch to the added sheet each time it's clicked?
Thanks.