View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Set CurrentRegion

If I you are saying that your data has no internal blank cells, and that
your data starts in A1, then you can use this macro to set the print area
for only the cells displaying a value...

Sub SetPrintArea()
Dim LastRow As Long, LastCol As Long
LastRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
LastCol = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column
ActiveSheet.PageSetup.PrintArea = Range("A1"). _
Resize(LastRow, LastCol).Address
End Sub

--
Rick (MVP - Excel)


"CR" wrote in message
...
All of the cells have formulas. Say, A1:AZ100 At times the visible data
only goes to columns AW or AX or AY. There are no blank cells in the rest
of the area .

If CurrentRegion won't work is there another way?


"JLGWhiz" wrote in message
...
Not if you are going to use the CurrentRegion.Address as the print area
parameters. Excel takes the entire range from top left to bottom right
cells as the print range. You would have to do a little manipulating if
you only want to pring the visible data and I am not sure I have the
expertise to tell you exactly how to do it.


"CR" wrote in message
...
I'm setting a print area using CurrentRegion.

Is there a way to have the current region ignore cells that only have a
formula in them?

Thanks
CR