How to Only Show Print Area in a Worksheet in Excel?


It might be difficult to show the important information without extraneous clutter when working with large or sophisticated spreadsheets. With Excel's helpful "Print Area" tool, you can choose a precise range of cells to print while eliminating any extraneous data outside of that area.

We will investigate how to define and show the print area in Excel in this tutorial. By printing only the desired content, you can more effectively convey your data by following these straightforward guidelines. This method can help you speed up the process and increase your productivity whether you need to produce expert reports, presentations, or any other publications based on your Excel worksheets. Let's get started and discover how to use Excel's "Print Area" tool to display only the pertinent content when printing.

Only Show Print Area in a Worksheet

Here we will use a VBA module to complete the task. So let us see a simple process to know how you can only show the print area in a worksheet in Excel.

Step 1

Consider an Excel sheet where you have a print area.

First, right-click on the sheet name and select View code to open the VBA application.

Right Click > View Code.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.

Code

Public Sub HideAllButPrintArea()
Dim xPrintRng As Range
Dim xFirstRng As Range
Dim xLastRng As Range
Application.ScreenUpdating = False
With Application.ActiveSheet
.Cells.EntireColumn.Hidden = False
.Cells.EntireRow.Hidden = False
If .PageSetup.PrintArea <> "" Then
Set xPrintRng = .Range(.PageSetup.PrintArea)
Else
Set xPrintRng = .UsedRange
End If
Set xFirstRng = xPrintRng.Cells(1)
Set xLastRng = xPrintRng.Cells(xPrintRng.Count)
If xFirstRng.Row > 1 Then
.Range(.Cells(1, 1), xFirstRng(-0, 1)).EntireRow.Hidden = True
End If
If xFirstRng.Column > 1 Then
.Range(.Cells(1, 1), xFirstRng(1, 0)).EntireColumn.Hidden = True
End If
If xLastRng.Row < .Rows.Count Then
.Range(xLastRng(2, 1), .Cells(.Rows.Count, 1)).EntireRow.Hidden = True
End If
If xLastRng.Column < .Columns.Count Then
.Range(xLastRng(1, 2), .Cells(1, .Columns.Count)).EntireColumn.Hidden = True
End If
End With
Application.ScreenUpdating = True
End Sub

Step 3

Then click F5 to run the module.

This is how you can only show the print area in Excel.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can only show the print area of a worksheet in Excel to highlight a particular set of data.

Updated on: 06-Sep-2023

63 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements