目前,我有以下代码通过在Sheet1中指定范围来识别Sheet2中特定范围的有效值列表 . 注释表1类似于事物数据库,而Sheet2则类似于表单 .

Set subRange = Worksheets("Sheet1").Range("A2:A14")
With Worksheets("Sheet2").Range("D6:D517").Validation
        .Delete
        .Add Type:=xlValidateList, Formula1:="='Sheet1'!" & subRange.Address
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With

接下来我想更新我的验证,以便Sheet2中的相同范围被限制在一个列表中,其中每个条目是Sheet1的同一行中两列的字符串连接 . 让Sheet1中的给定行为“r”,我希望验证列表中的项目为

' a concat of columns A and D infer the list entry
Worksheets("Sheet1").Cells(r,1).Value & Worksheets("Sheet1").Cells(r,4).Value

我计划使用数组来构建这个有限的列表,在Sheet1中的行上使用for循环,但我想知道是否有更好的方法来设置此验证限制 . 这似乎是一个相当普遍的行动 .