I want to open an existing excel work book and add a sheet with given name.. All this has to be done from a different excel work book
I am able to open the existing work book from a blank work book by executing code. But when I tired to add a new sheet to the opened work book, my code is adding the new sheet in the execution work book (Blank work book)
Sub Valuesets()
Dim ws As Worksheets
Dim PTable1 As PivotTable
Dim sheet As Sheets
Set wb = ActiveWorkbook
Workbooks.Open("C:\Users\user\Desktop\workbook1.xlsb").Worksheets("Data").Activate
On Error Resume Next
Application.DisplayAlerts = False
Sheets.Add Before:=ActiveSheet
ActiveSheet.Name = "Test-1"
Application.DisplayAlerts = True
Set CSheet = Worksheets("Data")
Set SSheet = Worksheets("Test-1")
End Sub