I have workbook with 2 worksheets.
"Sheet2" has two columns:
| A | B | +---------+---------------+ | code1 | description 1 | | code2 | Descr 2 | Sheet1 has several columns, one of them (column D) is code. In this column i need a "drop box", what
code from the col:A.It is possible to do without additional helper column in Sheet1? (Excel 2010)
So, need something what is dead simple in html:
<select> <option value="code1">Description 1</option> <option value="code2">Descr 2</option> </select> when when the user selects "Descr 2", the form get "code2".
This question probably is an duplicate - but i'm not sure - to: How to create dropdown with multiple columns in excel, but the only answer to it pointing me to an external site where the solution is for another problem.
Added a screenshot for more precise explanation: 
If you prefer not to create a named Excel table, you can create a named range, and use that as the source for a drop down list. The drop down lists can be on the same sheet as the source list, or on a different sheet.
Simple! Here is what we are going to get!

3 Steps Only:
Define a range to use as the lookup value
Create the dropdown list
Paste in some code
Sheet2 like this and define a Named Range as _descrLookup: 
( Highlight -> Right-Click -> "Define Name..." ) This is an optional step, but it just makes it easy to follow for Step 3.
Sheet1, create the dropdown using Data Validation and use the VALUES YOU WANT TO BE SHOWN IN THE DROPDOWN as the source. In this example it's Sheet2 A2:A4 (see above image): 
( Data -> Data Validation ) Sheet1: ( Right-Click the tab Sheet1 -> View Code ) Paste this into the code window for Sheet1:
Private Sub Worksheet_Change(ByVal Target As Range) selectedVal = Target.Value If Target.Column = 4 Then selectedNum = Application.VLookup(selectedVal, Worksheets("Sheet2").Range("_descrLookup"), 2, False) If Not IsError(selectedNum) Then Target.Value = selectedNum End If End If End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With