• Answers
  • Web
Answer 1 out of 1
 
258 helpful answers
A:

Ok, I really stumbled on this one.

 A friend got me through the hurdle.  And walked me through it.

So here goes.  Design the button, edit the code for it

here's the code for mine

rivate Sub CommandButton1_Click()

    Dim i, j As Integer

    ActiveSheet.Unprotect
   
    i = 2
    j = 2
    Do
       
        Do While Cells(j, 15) = "" And Cells(j, 1) <> "ENDOFLIST"
            j = j + 1
        Loop
               
        If j > i Then
            Range("A" & i & ":P" & j).Select
            Selection.EntireRow.Hidden = True
        End If
        i = j
       
        Do While Cells(j, 15) <> "" And Cells(j, 1) <> "ENDOFLIST"
            j = j + 1
        Loop
       
        Range("A" & i & ":P" & j).Select
        Selection.EntireRow.Hidden = False
        i = j
     
    Loop Until Cells(i, 1) = "ENDOFLIST"
   
    ActiveSheet.PageSetup.PrintArea = "$A$1:$p$" & i
    ActiveWindow.SelectedSheets.PrintPreview
 
    Range("A1:P" & i).Select
    Selection.EntireRow.Hidden = False
   
 
End Sub

'it's dynamic to the active sheet, so wow I really was impressed with the simplicity of it. 

Posted 2 years ago
Helpful?(2)
Rated as Best Answer
 
Comment About This Answer (or add your own answer)

Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
  • Answers
  • Web
Copyright © 2006-2009, Yedda Inc. and respective copyright owners