search and display names

HeRoseInThree

Board Regular
Joined
Jan 11, 2018
Messages
67
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!
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

DanteAmor

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

HeRoseInThree

Board Regular
Joined
Jan 11, 2018
Messages
67
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
11,075
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

Board Regular
Joined
Jan 11, 2018
Messages
67
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
11,075
Office Version
2007
Platform
Windows
That is because in cell H1 you have a data validation.
Delete that data validation.
 

Tom.Jones

Active Member
Joined
Sep 20, 2011
Messages
256
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
11,075
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

HeRoseInThree

Board Regular
Joined
Jan 11, 2018
Messages
67
Is there a way to also include another column?
The date is in column A, name in B and reason in C.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,320
Messages
5,443,770
Members
405,251
Latest member
shanezer

This Week's Hot Topics

Top