Monday, January 16, 2012

I Hate Page Break Previews (Part Deux)

Following through on last night's post, below is the VBA code I mentioned.  I'll assume you already know how to create procedures in your personal Excel workbook (maybe a future post will detail setting up Excel for development/advanced use...), and you know how/where to insert the code below.


Toggle Page Breaks On/Off:
Toggles page breaks on or off for the active sheet (currently selected sheet).
Sub PageBreaksOnOff()
    ActiveSheet.DisplayPageBreaks = Not ActiveSheet.DisplayPageBreaks
End Sub

Remove Page Breaks:
Removes page breaks for the active sheet (currently selected sheet).
Sub PageBreaksOff()
    ActiveSheet.DisplayPageBreaks = False
End Sub

Toggle Page Breaks On/Off for All worksheets in workbook:
Toggles page breaks on or off for ALL worksheets in active workbook.
Sub AllPageBreaksOnOff()
    Dim ws as Worksheet
    Dim wb as Workbook

    Set wb = ActiveWorkbook
    For each ws in wb.Worksheets
        ws.DisplayPageBreaks = Not ws.DisplayPageBreaks
    Next ws
    Set wb = Nothing
End Sub

Remove Page Breaks on All worksheets in workbook
Removes page breaks for ALL worksheets in active workbook.
Sub AllPageBreaksOff()
    Dim ws as Worksheet
    Dim wb as Workbook

    Set wb = ActiveWorkbook
    For each ws in wb.Worksheets
        ws.DisplayPageBreaks = False
    Next ws
    Set wb = Nothing
End Sub

Stay polar my furry friends.

No comments:

Post a Comment