|
|
|
|
|
|
Excel
|
Clear Print Area
|
|
Ease of Use
|
Easy
|
Version tested with
|
2002
|
Submitted by:
|
Zack Barresse
|
Description:
|
This macro clears the print area of every worksheet in a workbook.
|
Discussion:
|
When dealing with a workbook that has an abundance of sheets and you want to perform the same routine (Clearing the Print Area in this case) to all sheets, this little macro can save you some time and effort. Once complete, it brings you back to the sheet you started on, seemingly transparent to the untrained eye. This is great for troubleshooting printing problems because many people who share workbooks have problems due to print areas being set when it's not necessary.
|
Code:
|
instructions for use
|
Option Explicit
Sub ClearPrintArea()
Dim ws As Worksheet
Dim msg As String, _
orgWs As String
msg = "Are you sure you want to Clear Print Area on all sheets?"
If MsgBox(msg, vbYesNo) = vbNo Then Exit Sub
Application.ScreenUpdating = False
orgWs = ActiveSheet.Name
For Each ws In ThisWorkbook.Worksheets
ws.Activate
ActiveSheet.PageSetup.PrintArea = ""
Next ws
Sheets(orgWs).Select
Application.ScreenUpdating = True
End Sub
|
How to use:
|
- Copy the code above.
- Open a workbook.
- Hit Alt + F11 to open the Visual Basic Editor (VBE).
- Hit Alt + R to open the Project Explorer.
- Select desired file in left pane, go to Insert -> Module, from the menu.
- Paste the code into the code window that appears at right.
- Save the file, and close the VBE window (Alt + Q).
|
Test the code:
|
- From any sheet inside desired workbook, press Alt + F8, double-click ClearPrintArea. All print areas in workbook should be cleared.
|
Sample File:
|
ClearPrintArea.zip 9.25KB
|
Approved by mdmackillop
|
This entry has been viewed 124 times.
|
|