View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default 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.