VBA PDF Export of Large Spreadsheet

bifftannen

New Member
Joined
Mar 18, 2019
Messages
6
Good Day Gentleman,

I am hoping someone could help me out with the problem I am currently having - believe me that it would be beyond appreciated if anyone is willing to offer some of their time to help me with this.

Currently I have a very large spreadsheet(Approx 3080 Rows and with approx 908 columns) that I am working on exporting to PDF in 11x17 landscape mode.

Basically i've worked out how many columns and rows I can fit onto one page in Landscape @ 11x17 and my plan is to just break this document into sections going from top to bottom, and then move onto the next set of columns where I would go top to bottom all the way to the bottom row, then continue on.

Code:
Sub DebugPrint()
    
    With ActiveSheet.PageSetup
    .PrintArea = Range("A1:AN3080").Address
    
    .Orientation = xlLandscape
    .FitToPagesWide = 1
    .FitToPagesTall = False
    .PaperSize = xlPaper11x17
    End With
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:="C:\Test.pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
End Sub


Currently the code above works great. It will render 85 pages using columns A to AN on each page while incrementing the rows as the pages go on. So I get a great 11x17 landscape PDF document output as I want.

The problem I am having is I need to somehow move on to range "("AO1:CO3080")" and do the same thing so it builds 85 more pages to the same document with each page using columns AO to CO while incrementing the rows as the pages go on. And then after that i would do range ("CP1:DQ3080") etc, etc, etc.

Is there anyway to do this? I think one way of doing this would be running my function above, writing the PDF file, then changing the range to AO1:CO3080 and appending 85 more pages to that same PDF document, etc, etc. BUT the problem with that is I would need Adobe Acrobat Pro (which i cannot afford) in order to use their API to append documents.

Is there a way to do this using VBA only?

I've attached this quick drawing I made to kind of go along with my explanation (may or may not be helpful - if there is anything you need from me please let me know)

**Many thanks to anyone willing to spare some time to help me out here. Will pay it forward

vcOzk06.jpg
 
Please don't create clutter by quoting every post.
Does Row1 have data in all columns?
If not, change this
Code:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
to this
Code:
lc = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
or to
Code:
lc = ActiveSheet.UsedRange.Columns.Count

All the code does is copy every j columns (as per InputBox) below the first j Columns.
It then sets the print area for the length of Column A resized to the Column equivalent to whatever was entered in the InputBox (=j)
So if you say that your sheet will take 78 columns wide, that is the number to enter in the InputBox
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,921
Messages
6,122,280
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