A way to search by name or number in a data validation list and only return the name in that cell and the associated number in the adjacent cell?

Lisenbe

New Member
Joined
Aug 30, 2009
Messages
3
Is there a way to look up a name OR number in a data validation list but only let the user select the number and then have the associated number populate in the adjacent cell?
My goal is for users in a file to be able to see the project numbers and/or names (some users search by names and some by numbers) but only populate column A with numbers and column B with names.

I've tried data validation lists and xlookup but I cannot figure out how to let the users search A1 by both project number and project name and only select the project name.
I also would prefer no code if possible.
 

Attachments

  • Project Numbers and Names_Field Template.png
    Project Numbers and Names_Field Template.png
    15.4 KB · Views: 12

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Below is one way (but it does require code :()
  1. Combine the numbers and names into a single column as I have done in col H.
  2. Set up the Data Validation as shown below the mini sheet (I have applied it to A2:A10)
  3. Use the Worksheet_Change event code shown (If you need instructions for how to do that, post back)
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
 
  Set Changed = Intersect(Target, Range("A2:A10"))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      If Len(c.Value) > 0 Then
        c.Resize(, 2).Value = Split(c.Value, "|")
      Else
        c.Offset(, 1).ClearContents
      End If
    Next c
    Application.EnableEvents = True
  End If
End Sub

Here is my sheet after I have chosen a few items from the list

Lisenbe.xlsm
ABCDEFGH
1NumberNumberNumberNameDV List
21happy street1|happy street
32sad house2sad house2|sad house
43wet road3|wet road
54burning bridge4|burning bridge
64burning bridge5desk work5|desk work
75desk work
8
91happy street
10
Sheet1
Cell Formulas
RangeFormula
H2:H6H2=F2&"|"&G2
Cells with Data Validation
CellAllowCriteria
A2:A10List=$H$2:$H$6
 
Upvote 0
Like This ? (With Formula)

Row "B2"
Excel Formula:
=IFERROR(IF(A2="","",XLOOKUP(A2,F:F,G:G)),"")

1702432589009.png
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top