Question : Only Show Rows that contain specified name

I want to be able to enter a name in a certian cell (M1) for example and then have that name be the filter for which only rows in the spreadsheet that match that name be displayed.  I have created a spreadsheet for scheduling umpires for baseball and the umpires name may be in either column "G" or "H" and I want to be able to display all rows for a single umpire so that I can easily see where I have them scheduled.  I hope this makes sense.  If my report cell (M1) is empty, then I want to show all rows.  I have attached the spreadsheet I am working with.

Thanks in advanced,


Joey

Answer : Only Show Rows that contain specified name

Hi Joey

Please see attached.  You need to enable macros when you open it.  I have added a new named range (called Crit) which occupies Z1:Z2.  I use Advanced Filter to filter the records (so you won't see any drop down arrows).  I have used event code in the worksheet module which is:

Richard

PS you only need to type part of a name into M1 to return records where a partial match is achieved in either of the two umpire columns
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, lngCalc As Long
 
If Target.Address <> "$M$1" Then Exit Sub
If Me.FilterMode Then Me.ShowAllData
If Target.Value = "" Then Exit Sub
With Application
    .ScreenUpdating = False
    lngCalc = .Calculation
    .Calculation = xlCalculationManual
End With
Set r = Range("A1:H" & Cells(Rows.Count, "A").End(xlUp).Row)
With r
    .AdvancedFilter xlFilterInPlace, Range("Crit")
End With
Application.Calculation = lngCalc
End Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us