PDA

View Full Version : Hide empty rows



nbqleebarnes
12-05-2011, 12:55 AM
Hi All,
Been a long time since here,
anyway I picked up on the following code that hides empty columns, I would like to know if there is a way to do this with rows.
Thanks
Lee

Sub Button1_Click()
Dim Col_Ct As Integer, i As Integer
Col_Ct = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To Col_Ct
If WorksheetFunction.CountA(Range(Cells(1, i).Address, Cells(Rows.Count, i).Address)) < 2 Then
Cells(1, i).EntireColumn.Hidden = True
End If
Next i
End Sub

nilem
12-05-2011, 01:45 AM
maybe so
Sub Button2_Click()
Dim rws As Long, i As Long, Col_Ct As Long
rws = Cells(Rows.Count, 1).End(xlUp).Row
Col_Ct = Columns.Count
For i = 1 To rws
Cells(i, 1).EntireRow.Hidden = WorksheetFunction.CountA(Range(Cells(i, 1), Cells(i, Col_Ct))) < 2
Next i
End Sub

nbqleebarnes
12-05-2011, 02:22 AM
Hi Nilem,
Thanks for the response, I have attached the worksheet that I am trying to hide the rows, I would need to hide rows 189 to 292, although for each invoice there would be varying length's.
Thanks
Lee

nilem
12-05-2011, 05:34 AM
Sub ertert()
With Range("A24:A292")
.EntireRow.Hidden = True
.SpecialCells(2).EntireRow.Hidden = False
End With
End Sub