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 / February 2008

Tip: Looking for answers? Try searching our database.

Hiding row if first cell is empty (VBA)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalil Handal - 05 Feb 2008 19:34 GMT
Hi,
I have a worksheet (sheet2) used as a report. It should be printed on ONE
page A4 size.
Some rows between 7 and 25 have the first cell empty (no value is shown).
The values in the range A7:A25 are copied from another sheet (sheet1).
I need:
1-   VBA code or Macro to hide the rows were the corresponding cell in the
range A7:A25 is empty.
2-   the sheet to be printed on ONE A4 paper

Is this Possible??

Khalil
Gord Dibben - 05 Feb 2008 20:59 GMT
Easiest method may be to record a macro whilst using the Autofilter to show
non-blank rows then set your printrange and paper size.

The rows hidden by the filter will not print.

To get you started...........................

This macro will hide the rows that have a blank cell in column A.

You can record a macro whilst setting a printrange and paper size.

Incorporate the two.

Sub hide_zero_rows()
Dim c As Range
   With ActiveSheet.Range("A7:A25")
       Do
           Set c = .Find("", LookIn:=xlValues, LookAt:=xlWhole, _
                   MatchCase:=False)
           If c Is Nothing Then Exit Do
           c.EntireRow.Hidden = True
       Loop
   End With
End Sub

Gord Dibben  MS Excel MVP

>Hi,
>I have a worksheet (sheet2) used as a report. It should be printed on ONE
[quoted text clipped - 9 lines]
>
>Khalil
 
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.