Command Button

Herms

New Member
Joined
Apr 7, 2019
Messages
2
Good day.

I have 4 forms on one worksheet.

I need to place a command button with each form.
On click the relevant form needs to be saved as pdf on desktop.

Please advice
Regards and thank you in advance
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
10,240
Office Version
2007
Platform
Windows
Try this.
Change data in red by your information.

Code:
Sub Button1()
    Range("[COLOR=#ff0000]A1:C6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file1[/COLOR].pdf"
End Sub


Sub Button2()
    Range("[COLOR=#ff0000]D1:F6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file2[/COLOR].pdf"
End Sub


Sub Button3()
    Range("[COLOR=#ff0000]G1:I6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file3[/COLOR].pdf"
End Sub


Sub Button4()
    Range([COLOR=#ff0000]"J1:L6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file4[/COLOR].pdf"
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,090,116
Messages
5,412,520
Members
403,431
Latest member
Ghozi alkatiri

This Week's Hot Topics

Top