VBA: Print to pdf with custom or dynamic print area

IIII

New Member
Joined
Jan 26, 2021
Messages
18
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hi All - I currently have a code that prints one of my worksheets to pdf just fine however, I've run into a new problem. I've now noticed that sometimes the data that needs to be printed overlaps the print areas and is either not captured or it prints in a mess across multiple pages breaking up the tabled data. I just need it to print neatly if, it has to print across multiple pages. I do hope this makes sense. Otherwise, please ask for more info. Thank you.

For example, from the first date header to the last "Approved", this would be Page 1, then the small data below it, would be Page 2.

One of example csv sheets below, that currently overlap itself when printing to pdf.

DateShiftstart timeFinish TimeHoursKmsPTTP/HDay TypeStatus
Mon, 14 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5790.5NWkDayApproved
Mon, 14 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM2.5580.5NWkDayApproved
Mon, 14 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM2200.5NWkDayApproved
Mon, 14 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3860.5NWkDayEvApproved
Tue, 15 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM2.530.25NWkDayApproved
Tue, 15 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM41300.5NWkDayApproved
Wed, 16 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM51010.5NWkDayApproved
Wed, 16 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM5200.5NWkDayEvApproved
Thu, 17 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5440.5NWkDayApproved
Thu, 17 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5200.5NWkDayApproved
Fri, 18 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5200.5NWkDayApproved
Fri, 18 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM4100.5NWkDayApproved
Fri, 18 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM4960.5NWkDayEvApproved
Sat, 19 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM71510.5NWkEnd_SatApproved
Sat, 19 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM2430.5NWkEnd_SatApproved
Mon, 21 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.51240.5NWkDayApproved
Mon, 21 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM4400.5NWkDayApproved
Mon, 21 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3660.5NWkDayEvApproved
Tue, 22 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM2.530.25NWkDayApproved
Tue, 22 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM4710.5NWkDayApproved
Wed, 23 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM5890.5NWkDayApproved
Wed, 23 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM200NWkDay_ABCApproved
Thu, 24 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5350.5NWkDayApproved
Thu, 24 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5660.5NWkDayApproved
Fri, 25 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM3.5560.5NWkDayApproved
Fri, 25 Nov 2022Jane Doe - Services Lorem ipsum dolor sit amet dolor sit8:30 AM12:00 PM4310.5NWkDayApproved
Completed by:WkDay Hours67.5
IIIIWkDay Hours - PTT9
WkDayEv Hours15
Completed for:WkDayEV Hours - PTT2
IIIISat. Hours9
Sat. Hours - PTT1
Date Completed:Lorem ipsum dolor sit amet dolor sit amet1462
14/12/2022 3:37
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Can you just set a limit of rows per page, then calculate the continuous rows in each table, pad out rows to make up for the extra space in the page if you can't fit another table in the remaining space.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,184
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