View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_4_] Gary Brown[_4_] is offline
external usenet poster
 
Posts: 209
Default Print Range Question

'/========================================/
Sub Macro1()
Dim i As Long, lngLastRow As Long

Range("A1").Select

lngLastRow = _
ActiveSheet.UsedRange.Columns(1). _
SpecialCells(xlCellTypeLastCell).Row

For i = 1 To lngLastRow - 1
If ActiveCell.Offset(i, 0).Value2 = 0 And _
Not IsEmpty(ActiveCell.Offset(i, 0).Value2) Then
lngLastRow = ActiveCell.Offset(i, 0).Row - 1
Exit For
End If
Next i

ActiveSheet.PageSetup.PrintArea = "$A$1:$F$" & lngLastRow

End Sub
'/========================================/

--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"John" wrote:

I am trying to develp a macro that will set the Print Range in a worksheet. I
have tried to modify several macos on the forums with no success. The problem
is I need to count down to the bottom of column A (which does contain some
blanks), to the first row that contains 0. Then I want the macro to set the
Print Range to A1:FX, where X is equal to the last row before the 0.

Thanks in advance! (Using Excel 2003)