simple row deletion

G

Guest

simple request:

after using the auto filter tool, the rows that got sorted out have a height
= 0. I just want a program to delete rows in which the height is 0. or is
there sia way to set up the auto filter to do this, even better.

Sub row_delete()

For i = 1 To 1000

If Rows(i).RowHeight = 0 Then Rows("i").Delete Shift:=xlUp

Next i

End Sub
 
G

Guest

Two things. You have to do it backwards or consecutive rows of zero height
won't be deleted and the quotes aren't required:-

Sub row_delete()

For i = 1000 To 1 Step -1
If Rows(i).RowHeight = 0 Then Rows(i).Delete
Next i

End Sub

Mike
 
Z

Zone

Try going up instead of down. James

Sub RowsOut()
Dim k As Long
For k = 1000 To 1 Step -1
If Rows(k).EntireRow.RowHeight = 0 Then Rows(k).EntireRow.Delete
Next k
End Sub
 
J

Jim Rech

It's probably a little faster to do just one delete:

Sub DelZeroHeightRowsAfterAutoFilter()
Dim Cell As Range
Dim DelRows As Range
For Each Cell In Range("_FilterDatabase").Columns(1).Cells
If Cell.RowHeight = 0 Then
If DelRows Is Nothing Then
Set DelRows = Cell
Else
Set DelRows = Union(DelRows, Cell)
End If
End If
Next
If Not DelRows Is Nothing Then DelRows.EntireRow.Delete
End Sub


--
Jim
| simple request:
|
| after using the auto filter tool, the rows that got sorted out have a
height
| = 0. I just want a program to delete rows in which the height is 0. or is
| there sia way to set up the auto filter to do this, even better.
|
| Sub row_delete()
|
| For i = 1 To 1000
|
| If Rows(i).RowHeight = 0 Then Rows("i").Delete Shift:=xlUp
|
| Next i
|
| End Sub
|
|
 

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