Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No print for blank

Status
Not open for further replies.

danswear

MIS
Dec 15, 2005
4
US
I am setting up a macro in excel to print different selections on a drop down auto filter. I am putting in to print from 400 - 700, however, a lot of these pages would be blank and they print a blank page with headings. I need to add some code that would tell the macro to not print if that particular selection was empty.
 
Here is a snipit that will iterate through the AutoFilter range to check if Rows are visible and Exit at the first visible row.
Code:
Public Sub TestFilter()
Dim wksActive As Worksheet
Set wksActive = ActiveSheet
Dim filAutoFilter As AutoFilter
Dim rngRow As Range
Set filAutoFilter = wksActive.AutoFilter
For Each rngRow In filAutoFilter.Range.Rows
  'If row is visible and not part of the header row then print
  If Not rngRow.Hidden And rngRow.Row <> 1 Then
    'add your printing code here
    Exit For
  End If
Next rngRow
End Sub

Hope this helps,
CMP

Instant programmer, just add coffee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top