简体   繁体   中英

Default value within data validation given data in cell

Trying to get to display the default value of a data validation list on a cell contingent on the value (city in this example) input on a different cell.

Data and sample below:

在此处输入图片说明

For example, when I am filling-in the name and city of residence of someone in Madrid, I would like that cell "B3" to display the "Default Language" as specified in "Default Table".

Guidance will be greatly appreciated

Private Sub Worksheet_Change(ByVal Target As Range)

'Prerequisites
'Select the City range (from Madrid to Pontevedra) and name it rngCity using Formulas > Define Name
'Select the Language range (from Spanish to Gallician) and name it rngLanguage using Formulas > Define Name

Dim dblFind As Double

If Not Intersect(Target, Range("B2")) Is Nothing Then 'Detects if B2 has changed
    dblFind = WorksheetFunction.Match(Range("B2").Value, Range("rngCity"), 0)
    Range("B3").Value = Range("rngLanguage").Cells(dblFind)
End If

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM