Dynamically Change File Name – ComboBox Excel Print

How can I have the name of the pdf dynamically changed based on Sel_Manager (combobox1) ? The viewers would like to print multiple PDFs and show them on the screen at the same time. Thank you in advance!

Private Sub CommandButton1_Click()
Dim Sel_Manager As String
'Specify headers to be repeated at the top
With ActiveSheet.PageSetup
        .PrintTitleRows = "$5:$9"
        .PrintTitleColumns = "$B:$M"
        .Orientation = xlLandscape
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
End With

'Manager selection through simple Inputbox
 Sel_Manager = ComboBox1
'Insert autofilter for worksheet
'Select manager defined in inputbox
ActiveSheet.Range("B14", Range("M14").End(xlDown)).AutoFilter Field:=1, Criteria1:=Sel_Manager
 'Select range to be printed and specify manager in filename
ActiveSheet.Range("B14", Range("M14").End(xlDown)).Select

Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Manager.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True


End Sub

  • Excel/VBA - Userform overwriting existing data
  • For Each loop on Array to return count of each unique string
  • How to save a number starting with + and has a - in the middle in a .csv file
  • How to use VBA to make a cell in Excel 2007 transparent
  • Excel VBA + Fill multiple Text boxes based on values in ComboBox with or without loop
  • Which encoding opens CSV files correctly with Excel on both Mac and Windows?
  • Create group ID based on description
  • Grouping things in Excel
  • Using VB/VBA to search Outlook messages and extract specific data into Excel worksheet
  • Writing to Excel CSV with a for loop using Pandas
  • Bulk rename image assets with Excel
  • Why I cannot execute a code in an autofiltered data list in vba?
  • One Solution collect form web for “Dynamically Change File Name – ComboBox Excel Print”

    Answer found –

    Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Sel_Manager + ".pdf",
    MS Excel Spreadsheet is the best Office Software, Excel VBA and Excel Formulas make Spreadsheet work faster.