尝试将数据验证从VBA转换为VB.NET

时间:2019-11-23 21:32:48

标签: excel vb.net vsto

我有一些代码试图在其中构建数据验证框。我已经在VBA中设置了所需的设置,但是不确定在VB.Net中应该如何显示

我正在使用How to pass values from an array to a drop down list in a certain cell (not combo list) in excel VBA的Davy C的指南作为指导

原始数据验证代码可以在此处显示:

Dim myArray
myArray = Array("1", "2", "3")

Range("A" & 1).Select

With Selection.Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
    xlBetween, Formula1:=myArray(0) & "," & myArray(1) & "," & myArray(2)
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
End With

0 个答案:

没有答案
相关问题