+ Reply to Thread
Results 1 to 8 of 8

print every 44 lines (including blank lines) per page

Hybrid View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    print every 44 lines (including blank lines) per page

    Hi.

    I'm trying to print every 44 lines (including blank lines) per page.

    Sub TryPrint()
    ' I need print 44 rows per page
    For i = 1 To 19766 Step 44
        ActiveSheet.HPageBreaks.Add Before:=Cells(i + 1, 1)
    Next
    End Sub
    Thank you!!!
    Attached Files Attached Files
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: print every 44 lines (including blank lines) per page

    Maybe:

    Sub POMarreco(): Dim i As Long, r As Long, c As Long, PA As String, Q As Range
            r = Rows.Find("*", , , , xlByRows, xlPrevious).row
        c = Columns.Find("*", , , , xlByColumns, xlPrevious).Column
    For i = 1 To r Step 44
    Set Q = Cells(i + 43, c)
    PA = "$A$" & i & ":" & Q.Address
    ActiveSheet.PageSetup.PrintArea = PA
    ActiveSheet.PrintOut Copies:=1
    Next i
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: print every 44 lines (including blank lines) per page

    Thanks to respond.

    i have bad english, but i try explain.

    look my newfile, inside file has 45 row (colorful background), i need skip 1 blank row (sum total 45 per page).

    in file has 20.000 rows, i need print , 5 gruop date each 8 row (1 group + blanck cell, 2 group + blanck cell, 3 group + blanck cell, 4 group + blanck cell, 5 group + blanck cell) = 45 rows

    colors will try to clarify my explanation.

    Thank you!
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: print every 44 lines (including blank lines) per page

    Hi Marreco (Old Friend),

    This looks good:

    Sub POMarreco(): Dim i As Long, r As Long, c As Long, PA As String, Q As Range
            r = Rows.Find("*", , , , xlByRows, xlPrevious).Row
        c = Columns.Find("*", , , , xlByColumns, xlPrevious).Column
    For i = 1 To r Step 45:  Set Q = Cells(i + 44, c)
            PA = "$A$" & i & ":" & Q.Address
    With ActiveSheet.PageSetup: .PrintArea = PA: .Zoom = False
    .FitToPagesWide = 1: .FitToPagesTall = 1: End With
    ActiveSheet.PrintOut Copies:=1
    Next i: End Sub

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: print every 44 lines (including blank lines) per page

    Hi Great Friend.

    before running this macro on my computer (because there are many impressions), I want to print preview.

    I fear that I must preview before printing.

    how to change your code so that I can print preview?

    Thank you!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: print every 44 lines (including blank lines) per page

    Hi Marreco,

    The way I ran it for Print Preview was to just comment out the Printout Line. But the data was uneven so I added the SpacingData procedure - be sure to have a backup before you run it!

    Sub POMarreco(): Dim i As Long, r As Long, c As Integer, t As Integer, PA As String
            r = Rows.Find("*", , , , xlByRows, xlPrevious).row
    SpacingData: For i = 1 To r
    If Range("A" & i) = "Giro" Then
    If i > r - 7 Then Exit For
    Do Until Range("A" & i + 2) = "Cliente"
    Range("A" & i + 1).EntireRow.Delete Shift:=xlUp
    r = r - 1: Loop: End If: Next i
                t = Int(r / 45) + 1: PA = "$A1:$B$" & r
    With ActiveSheet.PageSetup: .PrintArea = PA: .Zoom = False
    .FitToPagesTall = t: End With
    'ActiveSheet.PrintOut Copies:=1
    ActiveWindow.SelectedSheets.PrintPreview
    End Sub
    After you get the print preview, you should just be able to hit the print button in your toolbar.

    Let me know of issues And, thanks for the rep!
    Last edited by xladept; 04-01-2014 at 03:21 PM.

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: print every 44 lines (including blank lines) per page

    Hi, great xladept, the code was wonderful!

    Your skills are amazing!

    thank you very much!

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: print every 44 lines (including blank lines) per page

    You're welcome old friend! And, thanks for the compliment

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Insert blank lines to make the total number of lines 67
    By raghuprabhu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 07:34 AM
  2. Replies: 0
    Last Post: 02-09-2012, 11:53 AM
  3. How do I print an excel spreadsheet including the matrix lines?
    By Lexus in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-22-2005, 11:05 PM
  4. how do I print a page with only grid lines showing
    By Ms. P. in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  5. how do I print a page with only grid lines showing
    By Paul0 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1