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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,166
Members
452,615
Latest member
bogeys2birdies

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