Collapsing filtered macro

  • Thread starter Thread starter DFrank
  • Start date Start date
D

DFrank

i ran a macro, and it deleted a bunch of error cells, but left a bunch of
blank cells such as the following:

a




b




c



how do i get it to collapse to the form:
a
b
c?

Prefereably within the same macro.

Thanks for any help.
 
If you sort the range by that column all the blanks should end up at the
bottom.
 
this may work for you (if those really are blanks):
Sub HideBlanks()

Dim rng As Range
On Error Resume Next
Range("A1:A20").EntireRow.Hidden = False '< -- Change this range to suit
your needs
Set rng = Range("A1:A20").SpecialCells(xlBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireRow.Hidden = True
End If

End Sub

This will unhide the blanks:
Sub UnHideBlanks()

Dim rng As Range
On Error Resume Next
Range("A1:A20").EntireRow.Hidden = False
Set rng = Range("A1:A20").SpecialCells(xlBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireRow.Hidden = False
End If

End Sub





Regards,
Ryan---
 
Back
Top