Public Sub DeleteHiddenRows()
Dim rDelete As Range
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Columns(1).Cells
If rCell.EntireRow.Hidden Then
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End Sub
One approach:
1) Edit>GoTo. Click "Special". Select "Visible Cells Only". Click OK
2) Copy the selection you just generated
3) Paste it onto a new, empty sheet (or PasteSpecial>Values if appropriate)
This will give you a new sheet with everything that was visible (and only
that which was visible) on the old sheet. You can then delete the old sheet
if desired (and if formulas haven't been broken).
Note that this method can be applied to filtered lists, outlines, etc. as
well.
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.