Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 84
Default Hiding Rows when printing

Hi, now J Latham provided this to me, I am no WHIZZ with formulas and
have finally found out where to put it. I wonder if some kind person
could help me out. Now this works without any run time errors but
does'nt do what it is supposed to do the whole sheet comes up empty
rows as well

The column and rows I wish to check and hide before printing are cells
J10 to J44 now each cell has a formula in it which picks up a postcode
from another sheet. If a cell from J10 to J44 does not have that
postcode in it I want the entire row hidden so it wont print.

A big thanks to the helpee
Stephen

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim mySpecialRange As Range
Dim anyCell As Range


Set mySpecialRange = Worksheets("Carlog"). _
Range("A1:A" & Worksheets("Carlog").UsedRange.Rows.Count)
'unhide any that may now have data in them
mySpecialRange.EntireRow.Hidden = False
'hide rows based on blanks in column A
'but cells have formulas in them so...
For Each anyCell In mySpecialRange
If anyCell = "" Then
anyCell.EntireRow.Hidden = True
End If
Next
End Sub


Now, all that needs to be done from your button is to tell Excel to
print
that sheet:


Sub PrepAndPrintCarlogSheet()
Sheets("Carlog").PrintOut
End Sub


Assign that macro to the button and you're done.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Hiding Rows when printing

Check your previous thread.

pano wrote:

Hi, now J Latham provided this to me, I am no WHIZZ with formulas and
have finally found out where to put it. I wonder if some kind person
could help me out. Now this works without any run time errors but
does'nt do what it is supposed to do the whole sheet comes up empty
rows as well

The column and rows I wish to check and hide before printing are cells
J10 to J44 now each cell has a formula in it which picks up a postcode
from another sheet. If a cell from J10 to J44 does not have that
postcode in it I want the entire row hidden so it wont print.

A big thanks to the helpee
Stephen

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim mySpecialRange As Range
Dim anyCell As Range

Set mySpecialRange = Worksheets("Carlog"). _
Range("A1:A" & Worksheets("Carlog").UsedRange.Rows.Count)
'unhide any that may now have data in them
mySpecialRange.EntireRow.Hidden = False
'hide rows based on blanks in column A
'but cells have formulas in them so...
For Each anyCell In mySpecialRange
If anyCell = "" Then
anyCell.EntireRow.Hidden = True
End If
Next
End Sub

Now, all that needs to be done from your button is to tell Excel to
print
that sheet:

Sub PrepAndPrintCarlogSheet()
Sheets("Carlog").PrintOut
End Sub

Assign that macro to the button and you're done.


--

Dave Peterson
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
Hiding rows on a sheet before printing pano Excel Worksheet Functions 5 February 11th 07 04:15 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
hiding then printing a row S S Excel Worksheet Functions 4 August 9th 06 09:56 PM
Hiding rows when printing DHallam Excel Discussion (Misc queries) 1 May 21st 06 11:30 AM
Hiding rows before printing DaveM Excel Discussion (Misc queries) 3 April 16th 05 11:38 AM


All times are GMT +1. The time now is 09:57 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"