Excel 组合框条件 If 语句检测空白
Excel Combo box conditional If statement to detect blank
我正在编写一个 If 语句来测试我是否在两个组合框中选择了一个选项。被选中的组合框是从具有两个值的数组生成的。其中一个单元格是空白的,因此组合框中的最高值是空白的。
我的 if 语句是
数组是
Private Sub cbApplicationSelection_Change()
If (eMassWelcome.cbwesitechoose.text = "") Then
eMassWelcome.cbApplicationSelection.text = ""
MsgBox "A website has not been selected. Please select a website from the dropdown and try again."
End If
Exit Sub
End Sub
这行得通。
问题是弹出窗口出现了 3 次,我不确定为什么。我试过 IsNull()
和 listindex = -1
。 IsNull()
不起作用,列表索引给了我与上面相同的结果。所有这些都是在 excel.
中用 vba 完成的
您是否为 cbApplicationSelection 放置了任何更改事件?如果是这样,当您更改它的值时,更改事件也会被触发。
Private Sub cbApplicationSelection_Change()
If eMassWelcome.cbwesitechoose.text = "" Then
MsgBox "A website has not been selected. Please select a website from the dropdown and try again."
End If
Exit Sub
End Sub
我正在编写一个 If 语句来测试我是否在两个组合框中选择了一个选项。被选中的组合框是从具有两个值的数组生成的。其中一个单元格是空白的,因此组合框中的最高值是空白的。
我的 if 语句是
数组是
Private Sub cbApplicationSelection_Change()
If (eMassWelcome.cbwesitechoose.text = "") Then
eMassWelcome.cbApplicationSelection.text = ""
MsgBox "A website has not been selected. Please select a website from the dropdown and try again."
End If
Exit Sub
End Sub
这行得通。
问题是弹出窗口出现了 3 次,我不确定为什么。我试过 IsNull()
和 listindex = -1
。 IsNull()
不起作用,列表索引给了我与上面相同的结果。所有这些都是在 excel.
您是否为 cbApplicationSelection 放置了任何更改事件?如果是这样,当您更改它的值时,更改事件也会被触发。
Private Sub cbApplicationSelection_Change()
If eMassWelcome.cbwesitechoose.text = "" Then
MsgBox "A website has not been selected. Please select a website from the dropdown and try again."
End If
Exit Sub
End Sub