View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Identify and Delete all Rows and Columns NOT in Print Area

Perhaps just another idea to play with:

Sub Demo()
Dim nr, nc, sr, sc

With Range(ActiveSheet.PageSetup.PrintArea)
nr = .Rows.Count
nc = .Columns.Count
sr = .Rows(1).Row
sc = .Columns(1).Column
End With

On Error Resume Next
Columns(1).Resize(1, sc - 1).EntireColumn.Delete
Rows(1).Resize(sr - 1).Delete

Range(Cells(nr + 1, 1), Cells(Rows.Count, Columns.Count)).Delete
Range(Cells(1, nc + 1), Cells(Rows.Count, Columns.Count)).Delete
ActiveSheet.UsedRange
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Keith Young" wrote in message
...
Sorry - I guess I was not clear enough. The rows and columns that need to
be deleted will need to be identified using VBA. In addition the

Print_Area
will need to be identified with code. In the end this code will need to

be
run on many sheets within a workbook, each of which has a specific (and
different) Print_Area already set.

Any ideas on how to do this?

Thanks for your help


"Cliff Myers" wrote in message
...
With you saying which rows and columns need to be deleted it seems

you've
already identified them. Just click rows 1 & 2, right click, click

delete,
now your data becomes E1:J34, now click columns A,B,C, & D, again right
click, click delete, now your data becomes A1:F34.

As long as you are not using a border on the cells after column F and

row
34
then nothing will print if no data exists.

HTH

"Keith Young" wrote in message
...
Basically , I am trying to figure a way to identify and delete entire

rows
and entire columns that do not intersct with the print area on a given
sheet.

For example, the print_area on Sheet1 is set to E3:J36. I would need

code
to delete Rows 1 and 2 and also Rows 37 through 65536. In addition,

Columns
A,B,C,D and Columns K through IV need to be deleted.

Is there a way to do this using the Intersect, or any other method?

Thanks in advance. Using Excel 2002.

Keith