Sorting by cell contents

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
I have a subscriber list where in column A the customer is labeled as 'inactive' or '7day' or 'Sunday' and then in column B:D are address and detail info. What I need is a way to hide all rows that have 'inactive' as the label in Column A. Additionally, If I have A4&A5 as a merged cell saying 'inactive' would that affect the code or would both rows disappear properly?

Thanks in advance!

Andrew
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi
Code:
Sub HideRow()

    Application.ScreenUpdating = False
     ' Dim R As Range
     ' Set R = Application.Intersect(Target, Range("A1:A10"))
     ' If R Is Nothing Then Exit Sub
    With ActiveSheet
        For Each cell In Range("A1:A10")
            If cell.Value = "inactive" Then
                cell.EntireRow.Hidden = True
            End If
        Next
    End With
    Application.ScreenUpdating = True

End Sub

Just change the range to fit your file in:
Code:
Range("A1:A10")
and it should work.
As for the merge... No it won't work, merge means only one(1) cell, so only the highest (A4 in your example) will be hidden.

Did this help?
 
Upvote 0
Code:
Sub Hide()

    Application.ScreenUpdating = False
    With ActiveSheet
        For Each cell In Range("A1:A10")
            If cell.Value = "HIDE" Then
                cell.EntireRow.Hidden = _
                Not cell.EntireRow.Hidden
            End If
        Next
    End With
    Application.ScreenUpdating = True

End Sub
Or also this one so you could "hide" and "un-hide" at will simply by activating the shortcut key of your choice... option+command+shift+H in my case...
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top