Collapsing filtered macro

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.
 
D

Debra Dalgleish

If you sort the range by that column all the blanks should end up at the
bottom.
 
R

ryguy7272

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---
 

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