Data Validation drop-down list - search column #1 and insert column #2

nuficek

Board Regular
Joined
Jul 20, 2016
Messages
54
Office Version
  1. 365
Platform
  1. Windows
Is there any way to create searchable data validation drop-down list for example for currencies where I can search country in column A and get currency from column B? I would like to start search and write first letters so it will automatically filter the results from column A. Then just click on the correct one and get result from column B. Something like VLOOKUP function.

example.xlsx
ABCD
1Europe UnionEURUSD
2United KingdomGBP
3USAUSD
4SwitzerlandCHF
Sheet2
Cell Formulas
RangeFormula
D1D1=VLOOKUP("USA",A1:B4,2,FALSE)
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Something like VLOOKUP function.
That's a viable path...
-Set in Sheet2, in A1:Bxx the table Country / Currency
-Set in a cell, for example D2, a data validation based on a List; as the source of the list insert =Sheet2!$A$1:$A$xx
Now add a WorksheetChange macro:
-rightclick on the tab with the name of the sheet you are working on, select Display code; this will open the vba editor.
-copy the following code and paste into the rigth frame on the vba editor
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$2" Then             '<<<<
    Application.EnableEvents = False
    Target.Value = Application.VLookup(Target.Value, Sheets("Sheet2").Range("A1:B20"), 2, False)
    Application.EnableEvents = True
End If
End Sub
Now when you select a Country from he data validation dropdown menu, the content of the cell will revert to its currency

If you wish to restrict the list as soon you start typing (thus not using the data validation menu) you will use a combobox to be populated dynamically on combobox change; or will use the standard combobox features.

Bye
 
Upvote 0
Solution
That's a viable path...
-Set in Sheet2, in A1:Bxx the table Country / Currency
-Set in a cell, for example D2, a data validation based on a List; as the source of the list insert =Sheet2!$A$1:$A$xx
Now add a WorksheetChange macro:
-rightclick on the tab with the name of the sheet you are working on, select Display code; this will open the vba editor.
-copy the following code and paste into the rigth frame on the vba editor
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$2" Then             '<<<<
    Application.EnableEvents = False
    Target.Value = Application.VLookup(Target.Value, Sheets("Sheet2").Range("A1:B20"), 2, False)
    Application.EnableEvents = True
End If
End Sub
Now when you select a Country from he data validation dropdown menu, the content of the cell will revert to its currency

If you wish to restrict the list as soon you start typing (thus not using the data validation menu) you will use a combobox to be populated dynamically on combobox change; or will use the standard combobox features.

Bye
Hi, thanks a lot. It works like a charm.
I also tried to use Combobox to enable "search as you type" feature as you suggested but I'm getting numbers instead of currency. What am I doing wrong?
 
Upvote 0
I also tried to use Combobox to enable "search as you type" feature as you suggested but I'm getting numbers instead of currency. What am I doing wrong?
I guess you didn't manage appropriately the combobox :biggrin:

If you go with the activex combobox, a simple solution is inserting a 2 columns control; then set the "ListFillRange" property to Sheet2!A1:Bxx so that both Country & Currency are visible; then set "BoundColumn" to 2, and "LinkedCell" to the destination cell. I suggest you also set MatchEntry property to MatchEntryComplete.
This way when you select a row (country & currency) you will automatically show the currency in the destination cell.

Working in this way, the Worksheet_Change macro has to be deleted; maybe you might use a Worksheet_SelectionChange to make the combobox visible only when the Currency cell is selected

HTH
Bye
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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