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
8,769
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
8,769
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
8,769
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
217
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
8,769
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

Forum statistics

Threads
1,081,753
Messages
5,361,093
Members
400,613
Latest member
Markdc123

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top