Hi all,
I am using the below code to extract worksheets from a given workbook and convert the worksheets into individual workbooks. My question is how do I augment the code to direct the newly created workbooks to a particular folder? Where would such code be inserted?
Thank you very much for feedback!
Sub new_wbs()
Dim i As Integer, s As String, w As String
Application.SheetsInNewWorkbook = 1
Application.ScreenUpdating = False
'
For i = 1 To Sheets.Count
s = ThisWorkbook.Sheets(i).Name
Workbooks.Add
w = ActiveWorkbook.Name
ThisWorkbook.Sheets(i).Copy after:=Workbooks(w).Sheets(1)
Application.DisplayAlerts = False
Workbooks(w).Sheets(1).Delete
Workbooks(w).Sheets(1).Name = s
Workbooks(w).SaveAs Filename:=s & ".xlsx", FileFormat:=51
Workbooks(s & ".xlsx").Close savechanges:=False
Application.DisplayAlerts = True
Next i
'
Application.ScreenUpdating = True
Application.SheetsInNewWorkbook = 3
End Sub
I am using the below code to extract worksheets from a given workbook and convert the worksheets into individual workbooks. My question is how do I augment the code to direct the newly created workbooks to a particular folder? Where would such code be inserted?
Thank you very much for feedback!
Sub new_wbs()
Dim i As Integer, s As String, w As String
Application.SheetsInNewWorkbook = 1
Application.ScreenUpdating = False
'
For i = 1 To Sheets.Count
s = ThisWorkbook.Sheets(i).Name
Workbooks.Add
w = ActiveWorkbook.Name
ThisWorkbook.Sheets(i).Copy after:=Workbooks(w).Sheets(1)
Application.DisplayAlerts = False
Workbooks(w).Sheets(1).Delete
Workbooks(w).Sheets(1).Name = s
Workbooks(w).SaveAs Filename:=s & ".xlsx", FileFormat:=51
Workbooks(s & ".xlsx").Close savechanges:=False
Application.DisplayAlerts = True
Next i
'
Application.ScreenUpdating = True
Application.SheetsInNewWorkbook = 3
End Sub