View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Some help with Printing code

'Place in a standard module
'-------------------------------
Sub OnlyPrintNonZero()
Dim rngArea As Excel.Range
Dim rngRow As Excel.Range
Dim strPrintArea As String

Set rngArea = Worksheets("Master Page").UsedRange.Rows

For Each rngRow In rngArea
If Application.Sum(rngRow) 0 Then
strPrintArea = Range(rngArea(1), rngRow).Address
Worksheets("Master Page").PageSetup.PrintArea = strPrintArea
Exit For
End If
Next
Set rngRow = Nothing
Set rngArea = Nothing
End Sub
'---------
'Place in ThisWorkbook module
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Call OnlyPrintNonZero
End Sub
'----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Dean" wrote in message ups.com...
Gary,

The code above highlighted both tabs my data page and master page but
progressed no further.

The code only needs to print off my master page.

Appreciate your assistance.