Macro to Export range a PDF -columns to be on one page

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have written code to export a range named "Journals" ("A42:E150")

I need the code amended so that Column A:E fits on page




it would be appreciated if someone could assist me


Code:
Sub Export_Journals_as_PDF()

 Application.ScreenUpdating = False
Range("Journals").Select
ActiveSheet.PageSetup.Zoom = 150
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\My Documents\" & "\" & ActiveSheet.Range("A42").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveSheet.PageSetup.Zoom = 100
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Range("Journals").Select
ActiveSheet.PageSetup.Zoom = 100


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\My Documents\" & "\" & ActiveSheet.Range("A42").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveSheet.PageSetup.Zoom = 100
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Something like this ...
VBA Code:
Sub Export_Journals_as_PDF()

    With ActiveSheet.PageSetup
        .PrintArea = "$A$42:$E$150"
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\My Documents\" & ActiveSheet.Range("A42").Value & ".pdf", _
                                    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

End Sub
 
Upvote 0
Thanks for the help-Code works perfectly
 
Upvote 0
You're welcome & thanks for letting me know.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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