Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Hide Empty Rows When Printing

I am using this code to hide all of my empty rows when printing. How can I
start at row 6 so that my header does not get hidden?


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Production" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
On Error Resume Next
.Columns("A").SpecialCells(xlCellTypeBlanks).Entir eRow.Hidden =
True
.PrintOut
.Columns("A").SpecialCells(xlCellTypeBlanks).Entir eRow.Hidden =
False
On Error GoTo 0
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub

Thank you for you help,
Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Hide Empty Rows When Printing

Instead of Columns("A"), use:

Columns("A").Resize(Rows.Count - 5).Offset(5)

--

Vasant


"Bob" wrote in message
...
I am using this code to hide all of my empty rows when printing. How can I
start at row 6 so that my header does not get hidden?


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Production" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
On Error Resume Next
.Columns("A").SpecialCells(xlCellTypeBlanks).Entir eRow.Hidden =
True
.PrintOut
.Columns("A").SpecialCells(xlCellTypeBlanks).Entir eRow.Hidden =
False
On Error GoTo 0
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub

Thank you for you help,
Bob



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Macro to hide empty rows nLeBlanc21 Excel Discussion (Misc queries) 4 January 19th 10 10:04 PM
hide empty rows on open Joshy Excel Discussion (Misc queries) 1 August 28th 09 01:52 PM
How can i auto hide empty rows in printing in excel? TM Excel Discussion (Misc queries) 3 August 1st 08 07:42 PM
Is there a way to automatically hide empty rows? Christine Excel Worksheet Functions 1 April 12th 07 10:22 PM
Hide Empty Rows When Printing Bob Excel Worksheet Functions 5 August 20th 05 12:57 PM


All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"