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

Forum statistics

Threads
1,081,535
Messages
5,359,365
Members
400,525
Latest member
swwber

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top