Consulting

Results 1 to 5 of 5

Thread: Solved: Print pages that contain data

  1. #1
    VBAX Tutor
    Joined
    Jan 2006
    Posts
    248
    Location

    Solved: Print pages that contain data

    I want to print pages that contain data only, rows 1 & 2 have headers and there is also a custom header, the page setup also has rows 1 & 2 repeating for each page.

    How can I modify the following macro to only print the pages that contain data from row 3.

    The following macro that I have wants to print about 50 pages because the page setup has rows 1 & 2 repeating.

    HTML Code:
    Private Sub CommandButton3_Click()
    Dim LastRow As Long
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    .PageSetup.PrintArea = "A3:I" & LastRow
    End With
    End Sub
    Thanks for any help

  2. #2
    Not quite sure what you are after.
    Are there gaps in the data resulting in blank pages?
    (e.g. There is data down to row 2500 but there are gaps above such that some of the printed pages are blank).

  3. #3
    VBAX Tutor
    Joined
    Jan 2006
    Posts
    248
    Location
    I have included a copy of the file, when in print preview it only shows the pages that have data in them, but when you go to print it keeps printing, is this because rows 1 & 2 repeat for each page and the custom header?
    Attached Files Attached Files

  4. #4
    Have you tried setting your print range starting at A1 instead of A3?

  5. #5
    VBAX Tutor
    Joined
    Jan 2006
    Posts
    248
    Location
    Thanks jolivanes that seems to have worked, I had tried that earlier with a slightly different version of the macro.

    Thanks again I will mark it as solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •