Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I delete all rows and columns that are outside a worksheets
print area? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
set area in excel not giving me option to set print area? | Excel Discussion (Misc queries) | |||
File, print area, clear area, is not working | New Users to Excel | |||
How do you turn off a print area for a page? (no print area) | Excel Discussion (Misc queries) | |||
Macro to delete columns and set print area | Excel Programming | |||
Identify and Delete all Rows and Columns NOT in Print Area | Excel Programming |