尝试在单元格上显示数据验证列表的默认值,该列表取决于不同单元格上的值(本示例中的城市)输入。
以下数据和示例:
例如,当我填写马德里某人的姓名和居住城市时,我希望该单元格“B3”显示“默认表格”中指定的“默认语言”。
指导将不胜感激
答案 0 :(得分:1)
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