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 / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Hide Print Unhide

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalil Handal - 03 Mar 2008 18:34 GMT
Hi,
I need a macro (VBA Code)  to:
1- unprotect sheet with password="111"
2-  HIDE empty rows between 7 and 159 (7, 159 are included)
3-  Print the range A4:D160
4-  UNHIDE all rows between 7 and 159
5- Protect sheet with password="111"

Recording macro will not work because the empty rows are different each time

Khalil
Ron de Bruin - 03 Mar 2008 18:54 GMT
Hi Khalil

Start here
http://www.rondebruin.nl/print.htm#Hide

Maybe this one ?
Add you protect en unprotect code lines to the macro

*************************************
Hide Empty rows, Print and unhide the rows

This example will loop through every row in the range
Set rng = Sheets("Sheet1").Range("A1:A30")

If every cell in column A:G is empty it will hide that row.
After the loop it print the sheet and then unhide the rows.

Change "A1:G1" in the macro to the cells you want.
You can also use this with non contiguous ranges like "B1,D1:G1"

Sub Hide_Print_Unhide()
   Dim rw As Long
   Dim rng As Range
   Dim cell As Range

   Application.ScreenUpdating = False

   Set rng = Sheets("Sheet1").Range("A1:A30")

   With rng.Columns(1)
       For Each cell In rng
           If Application.WorksheetFunction.CountA( _
              .Parent.Cells(cell.Row, 1).Range("A1:G1")) = 0 Then _
              .Parent.Rows(cell.Row).Hidden = True
       Next cell
       .Parent.PrintOut
       .EntireRow.Hidden = False
   End With

   Application.ScreenUpdating = True
End Sub

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> Hi,
> I need a macro (VBA Code)  to:
[quoted text clipped - 7 lines]
>
> Khalil

Rate this thread:






 
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.