![]() |
delete everything but print area
How can I delete all rows and columns that are outside a worksheets
print area? Thanks. |
delete everything but print area
You can try this to hide the rows and columns
Sub Test() Dim rng As Range Dim FirstEmptyRow As Long Dim FirstEmptyCol As Integer With ActiveSheet.PageSetup Set rng = Range(.PrintArea) End With FirstEmptyCol = rng.Cells(rng.Cells.Count).Column + 1 FirstEmptyRow = rng.Rows.Count + rng.Cells(1).Row Range(Cells(1, FirstEmptyCol), Cells(1, 256)).EntireColumn.Hidden = True Range(Cells(FirstEmptyRow, 1), Cells(Rows.Count, 1)).EntireRow.Hidden = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl wrote in message oups.com... How can I delete all rows and columns that are outside a worksheets print area? Thanks. |
delete everything but print area
Sub DDD()
Dim rng As Range, lastRow As Long Dim lastCol As Long, i As Long Dim rw As Range, col As Range Set rng = ActiveSheet.UsedRange lastRow = rng.Rows(rng.Rows.Count).Row lastCol = rng.Columns(rng.Columns.Count).Column For i = lastRow To 1 Step -1 Set rw = Rows(i) If Intersect(rw, Range("Print_Area")) Is Nothing Then rw.EntireRow.Delete End If Next For i = lastCol To 1 Step -1 Set col = Columns(i) If Intersect(col, Range("Print_Area")) Is Nothing Then col.EntireColumn.Delete End If Next ActiveSheet.UsedRange End Sub -- Regards, Tom Ogilvy wrote in message oups.com... How can I delete all rows and columns that are outside a worksheets print area? Thanks. |
All times are GMT +1. The time now is 02:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com