0

尝试在一个单元格上显示数据验证列表的默认值,具体取决于不同单元格上的值(本例中为城市)输入。

数据和样本如下:

在此处输入图像描述

例如,当我填写马德里某人的姓名和居住城市时,我希望该单元格“B3”显示“默认表”中指定的“默认语言”。

指导将不胜感激

4

1 回答 1

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
于 2013-05-23T09:27:39.117 回答