我知道如何使用数据验证来实现,但我想添加一个参数。
我希望数据验证公式仅在“A109”=“test1”或“test2”时运行。
我在下面尝试了这个,但它没有给我想要的。无论如何,数据验证公式都在运行。
Sub Macro2()
If Range("A109").Value = "Test1" Or "Test2" Then
Range("B111").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=NOT(ISBLANK(B109))"
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "ATTENTION!"
.InputMessage = ""
.ErrorMessage = _
"Vous ne pouvez faire la remise en service tant que vous n'avez pas approuvé le ""...."" ou ""...."" à la cellule B109."
.ShowInput = True
.ShowError = True
End With
Sheets("Grille").Select
Else
Stop
End If
End Sub