Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / February 2007

Tip: Looking for answers? Try searching our database.

Hiding Rows when printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pano - 23 Feb 2007 05:46 GMT
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 - 23 Feb 2007 13:13 GMT
Check your previous thread.

> 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
[quoted text clipped - 36 lines]
>
> Assign that macro to the button and you're done.

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.