search and display names

HeRoseInThree

New Member
Joined
Jan 11, 2018
Messages
49
My company hires few people, yet many apply. That being said, I would like to sort through the list of applicants to determine if they have previously applied as to not waste time on someone that we have chosen not to hire.

I'd like to search their name in a cell (k12) and have it display a cell is the reason we passed.

I have tried a vlookup formula, an index formula as well as find and search respectfully.

Any help would be greatly appreciated!
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,682
Office Version
2007
Platform
Windows
You can put some examples with fictitious data of how your data is on the sheets.
 

HeRoseInThree

New Member
Joined
Jan 11, 2018
Messages
49
bc
1John SmithLives in the wrong area
2Jim Davisno CDL
3John Doemultiple speeding violations

<tbody>
</tbody>


This list is hundreds of names long. If I have a search box in h1, I'd like to be able to type John and have a result list of any and all names John displayed (column b) as well as the description of why we didn't hire them (column c).
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,682
Office Version
2007
Platform
Windows
Following your example: names in B, description in C.
Write a name in H1 and the result will be in H2 and I2 down.
Put the following macro in the events of your sheet.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Target.Address(0, 0) = "H1" Then
    Range("H2:H" & Rows.Count).ClearContents
    If Target.Value = "" Then Exit Sub
    Dim a() As Variant, b As Variant, i As Long, n As Long
    a = Range("B1:C" & Range("B" & Rows.Count).End(xlUp).Row).Value
    ReDim b(1 To UBound(a, 1), 1 To 2)
    n = 1
    For i = 1 To UBound(a)
      If InStr(1, LCase(a(i, 1)), LCase(Target.Value)) > 0 Then
        b(n, 1) = a(i, 1)
        b(n, 2) = a(i, 2)
        n = n + 1
      End If
    Next
    Range("H2").Resize(UBound(b), 2).Value = b
  End If
End Sub
SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 

HeRoseInThree

New Member
Joined
Jan 11, 2018
Messages
49
I pasted it into the correct area. I received an error.
The value you entered is not valid.

A user has restricted values that can be entered into this cell.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,682
Office Version
2007
Platform
Windows
That is because in cell H1 you have a data validation.
Delete that data validation.
 

Tom.Jones

Board Regular
Joined
Sep 20, 2011
Messages
197
For me, DanteAmor's cod works very good.

A user has restricted values that can be entered into this cell.
Sound like you have a DV in H1:In

Ooops forget to refresh...
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,682
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

Forum statistics

Threads
1,077,674
Messages
5,335,606
Members
399,028
Latest member
greyland

Some videos you may like

This Week's Hot Topics

Top