View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Frank_Hamersley Frank_Hamersley is offline
external usenet poster
 
Posts: 12
Default Tips for optimising page setup .Zoom and .FitTo properties

"Paul Robinson" wrote
Should be adaptable though?


Paul,

Have found a small bug in your function that you might like review.

It relates the ActiveSheet.UsedRange.Width property returning the number of
Points to the top left of the last cell in the range - ie. it does not
include the width of this last column (or height of the last row). The
mod'ed code now looks like ....

' Get the visible range in points - ensuring it rounds up
With ActiveSheet.UsedRange
lngUsedWidth = CLng(.Width + .Columns(.Columns.Count).Width + 1#)
lngUsedHeight = CLng(.Height + .Rows(.Rows.Count).Height + 1#)
End With

I suspect this will work even if the last column or row is hidden because
Excel reports the Width or Height of such columns/rows as 0 points.

As Agent 86 would have said its the "old top left corner mentality yet
again"! Not a very intuitive arrangement although it is consistent - and
too late to change Excel now.

Regards,
Frank.