I have a macro that will hide unused rows in a spreadsheet, print the 
active sheet, then unhide the rows.   
Spreadsheet is from cell A1 to P175.   Base info is recorded in various 
cells on rows 1 to 4.
Cells 5 to 16 display output.
 
The main Data input starts in cell A18 to G 167.   A18 is a from date, B18 
to date, with comments in column P.
Because I have 150 lines that could be used, I want to hide unused rows 
when printing to reduce the pages.
Rows 168 to 175 display results and are not hidden.
 
Here is the macro I have.  It works but runs very slowly.  I'm lookig for 
ways to speed it up.
 
Option Explicit
Sub PrintNonBlankColA()
  Dim RowCrnt As Integer
  Dim RowLast As Integer
 
  ' Note: This operates on the active worksheet
  Application.ScreenUpdating = False
  RowLast = Cells.SpecialCells(xlCellTypeLastCell).Row
 
  ' Hide all rows with a used cell and column "A" empty
  For RowCrnt = 18 To RowLast
    If IsEmpty(Cells(RowCrnt, "A")) Then
      Range(RowCrnt & ":" & RowCrnt).EntireRow.Hidden = True
    End If
  Next
  
    Range("A1:Q175").Select
    ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$175"
    
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
      
    Rows("17:168").Select
    Selection.EntireRow.Hidden = False
    Range("B2").Select
    
  End Sub
 
any suggestions to speed it up appreciated.
Mel
 

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to