Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MACRO to Conditionally Hide Rows

Status
Not open for further replies.

CBFISH

Technical User
Dec 23, 2004
8
US
I am trying to build an financial statement input workbook, and I'd like to have a macro that would hide rows that don't have any data.

i.e.

|1999 | 2000 | 2001
A | 51 | |
B | 60 | 10 | 25
C | | |
D | | 80 | 15

In this Case I would like to Hide Row "C". Keep in mind that Row 1 of the Spreadsheet has the Description.
 
Assuming this is Excel, the command is something like:

Rows("1:1").EntireRow.Hidden = True

Your code would have to determine which row was empty.
 
Hi CBFISH,

You could try something like this ..
Code:
[blue]For Each r In ActiveSheet.UsedRange.Rows
    If r.Find("*") Is Nothing Then r.EntireRow.Hidden = True
Next[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top