Code to save excel dashboard into pdf based on name in drop down list

TyeReece

Board Regular
Joined
Aug 3, 2007
Messages
136
I have a dashboard that uses a drop down box of close to two hundred names in it (named range = programlist). Each time I select a new name, the dashboard changes. Is there vb code that will loop thru the names and save each file as a pdf (or print to pdf printer) using the name of the program selected in the drop down list and the date?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this,

Code:
[COLOR=#d3d3d3]'[/COLOR]
[COLOR=#0000cd]Private Sub CommandButton1_Click()

Dim strFilename As String
Dim idx         As Long

On Error GoTo Hell

ActiveWorkbook.Sheets("Dashboard").Activate

For idx = 0 To (Me.ComboBox1.ListCount - 1)
    Me.ComboBox1.ListIndex = idx
    Me.Calculate
    Do Until Application.Ready
        DoEvents
    Loop
    strFilename = "D:\Reports\" & Me.ComboBox1 & ".pdf"
    Application.DisplayAlerts = False
        Me.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFilename, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        Application.StatusBar = " Saving " & strFilename
    Application.DisplayAlerts = True
Next

GetOut:
Application.DisplayAlerts = True
Application.StatusBar = vbNullString
Exit Sub

Hell:
MsgBox "Error # " & Err.Number & vbNewLine & vbNewLine & Err.Description, vbCritical, "Notification"
Resume GetOut

End Sub
[/COLOR][COLOR=#d3d3d3]'
'[/COLOR]
 
Upvote 0
This looks like it would work but instead of a combo box I have cell A4 as a data validation list (=ProgramList). How do I replace that section of code with something that just references the data validation list? Or do I have to insert a combo box?
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top