Advertisement

Excel Macro - Save multiple files to specific folders by inputting from a popup box

Excel Macro  - Save multiple files to specific folders by inputting from a popup box Topic: Excel Macro - Save multiple sheets as separate PDF files to specific folders by inputting from a popup box
Scenario: After you split a master file into multiple small sub-tabs, you want to save the sheets as separated files into different folders
Function: Macro for Copy sheet, AutoFilter, and Loop

Sub SplitandFilterSheetandSavePDFtoSpecificFolder()
'Step 1 - Copy sheet
'Step 2 - Filter by Department and delete rows not applicable
'step 3 - Loop until the end of the list
Dim Path As Variant
Dim FileName As Variant

Dim Splitcode As Range
Sheets("Master").Select
Set Splitcode = Range("Splitcode")

For Each cell In Splitcode
Sheets("Master").Copy After:=Worksheets(Sheets.Count)
ActiveSheet.Name = cell.Value

With ActiveWorkbook.Sheets(cell.Value).Range("MasterData")
.AutoFilter Field:=6, Criteria1:="NOT EQUAL TO" & cell.Value, Operator:=xlFilterValues
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

ActiveSheet.AutoFilter.ShowAllData

'save splitted files to PDF
Path = InputBox("Please input the file path you'd like to save this file to (eg. E:\Test)")
FileName = ActiveSheet.Name & " Employee Data.pdf"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=Path & "\" & cell.Value & " Employee Data.pdf", _
OpenAfterPublish:=False

MsgBox "Note: This file is now saved with the name of " & FileName & " in " & Path & "."
Next cell


End Sub

******Follow-up Consulting Services******
If you have specific question regarding your issue, you can email me at the email here Note that there will be a fee of US$50 charged for solving your issue. The turnaround is within 24 hours. Any follow-up issue in 3 days will also be answered with no charge. Payment link:


******More Videos in Playlists******
Excel for HR
Excel for HR - Master Class
Excel Macro - Beginner
Excel Macro/VBA - Splitting a Master File
Excel Charts Data Visualization
Excel Vlookup Function
Excel Pivot Table Function
Excel Array Function
Excel Index and Match Function
Excel Solver/Goal Seek Functions
Excel Cell Formatting Solutions
HR Analytics - Merit Matrix
HR Analytics - Salary Structure
Excel Tricks
Excel Troubleshooting
Fun HR Topics

For more successful stories, view at:

******Tools I use for this channel******
Channel management:
"I Love Spreadsheets" Mug:

#ExcelforHR#HRAnalytics#Excel#HR

HR analytics,Excel for HR,Excel training,Excel tutorial,Save Multiple Sheets as Separate PDF Files,Save Multiple Sheets as Separate Files,save sheet as pdf,how to use macro to divide sheet,split excel file into multiple files by row vba,excel sheet save as pdf,save to pdf,split a master tab into multiple sub tabs,split excel file into multiple sheets by row,split excel file into multiple worksheets,split excel file into multiple files by sheet,

Post a Comment

0 Comments