Hi All. I am modifying a previously created macro that I need to create a new folder and then have certain tabs copied into new workbooks in the newly created folder. I am stuck on where to add the code to save the files into the new folder. Any and all help is appreciated.
Code:
Sub SplitEachWorksheetDaily()
Dim FPath As String
Dim TexttoFind As String
TexttoFind = "Daily"
FPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set fso = CreateObject("Scripting.FileSystemObject")
'Create NewFolder
FolderName = Format(Date, "mm-dd-yyyy")
fso.createfolder "C:\Users\bfleenor\Desktop\" & FolderName
For Each ws In ThisWorkbook.Sheets
If InStr(1, ws.Name, TexttoFind, vbBinaryCompare) <> 0 Then
ws.Copy
Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".xlsx"
Application.ActiveWorkbook.Close False
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Finished"
End Sub