Hide empty rows in Excel worksheets

  • Thread starter Thread starter rixanna
  • Start date Start date
R

rixanna

I'm working on a program that enabled the user to insert 10 information
and print them. I developed the forms using VBE.
I have specified all the information into their own cells in Excel
worksheets.

When the user insert Info1, the data will directly go to Row 2, Column
1 in Excel worksheet. When the user insert Info2, the data will
directly go to Row3, Column 1. Each info has their own formula.

What I wanted to do now is that, if let say, the user didn't insert
Info1, I want the program to automatically hide the row specified for
Info1, so that when the user print the form, the empty row is not on
the paper.

I tried to use this code, but it doesn't seems to work. Maybe because I
have specified the formula in the cells.

Code:
For i = 2 To 4
If Worksheets("PCR-Master").Cells(i, 1).Text <> "" Then
Worksheets("PCR-Master").Rows(i).EntireRow.Hidden = True
End If
Next i



Any ideas?
Thank in advanced
 
Your code seems to do the opposite of what you want.

You have said that if the cell text is NOT blank, then hide the row. Try
changing <> to = and see if that helps.
 
I'm actually used this sign ' = '. But, it doesn't worked out. However,
when I used this sign '<>', it does worked out, when it hides all the
cells that contain data.
Why is it so? I'm so confuse........
 
So when you use <> does it hide the rows that appear blank as well? If so,
then the cells are not actually blank (could they contain a formula, or
perhaps a space or other invisible character?)

If it is hiding the cells with data, but not the blank ones, then I'm
stumped. Substituting + for <> should completely reverse the formula.

Try using Value instead of Text. No real reason why this should work, but it
might be worth a try.

I'm going to be away for a few days now, so if this doesn't work, perhaps
someone lese can suggest a solution?
 
Back
Top