Macro to HIDE blank rows

J

JForsyth

I have seen a couple of threads on how to create a macro to DELETE blank rows
but this is not what I'm looking for. I need to be able to simply HIDE the
blank rows. Does anyone know how to do this?
 
J

Jacob Skaria

Try the below

Sub Hideemptyrows()
For lngRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If WorksheetFunction.CountBlank(Rows(1)) = Columns.Count _
Then Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
 
M

muddan madhu

Sub row_hide()

Dim rng As Integer, i As Integer

rng = Cells(Rows.Count, "A").End(xlUp).Row

For i = 1 To rng
Cells(i, "A").Select
x = Application.WorksheetFunction.Count(ActiveCell.EntireRow)
If x = 0 Then ActiveCell.EntireRow.Hidden = True
Next i
End Sub
 
J

JForsyth

Thanks for writing back! Unfortunately it's not working...when I run it, the
rows don't become hidden...any suggestions?
 
J

Jacob Skaria

Oops. That was my mistake.Try the below

Sub Hideemptyrows()
For lngRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If WorksheetFunction.CountBlank(Rows(lngRow)) = Columns.Count _
Then Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
 
J

JForsyth

Thank You!!!! It works perfectly!

Jacob Skaria said:
Oops. That was my mistake.Try the below

Sub Hideemptyrows()
For lngRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If WorksheetFunction.CountBlank(Rows(lngRow)) = Columns.Count _
Then Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
 
J

JForsyth

Thank you!!! This works perfectly!!!

Jacob Skaria said:
Oops. That was my mistake.Try the below

Sub Hideemptyrows()
For lngRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If WorksheetFunction.CountBlank(Rows(lngRow)) = Columns.Count _
Then Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top