Hi All,
I'm attempting to download all excel worksheets as pdf files using a macro (as per below), however the file names of the exported files are based off the worksheet names and I need them to be based off the contents of specific cells instead.
Can anybody help me to name the files according to specific cells rather than the worksheet names please?
Sub Export_All_Invoices()
Dim Folder_Path As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select the Folder Path"
If .Show = -1 Then Folder_Path = .SelectedItems(1)
End With
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.ExportAsFixedFormat xlTypePDF, Folder_Path & Application.PathSeparator & sh.Name & ".pdf"
Next
MsgBox "Done"
End Sub
I'm attempting to download all excel worksheets as pdf files using a macro (as per below), however the file names of the exported files are based off the worksheet names and I need them to be based off the contents of specific cells instead.
Can anybody help me to name the files according to specific cells rather than the worksheet names please?
Sub Export_All_Invoices()
Dim Folder_Path As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select the Folder Path"
If .Show = -1 Then Folder_Path = .SelectedItems(1)
End With
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.ExportAsFixedFormat xlTypePDF, Folder_Path & Application.PathSeparator & sh.Name & ".pdf"
Next
MsgBox "Done"
End Sub