为什么if语句后我的消息框不触发?

时间:2019-10-15 15:04:37

标签: vba msgbox

我对VBA还是很陌生,但是我的msgbox函数遇到了问题。本质上,我是从下拉列表中选择一个名称,如果选择了某个名称,则会弹出一个消息框。由于某些原因,即使条件为真,它也不想触发。编辑:下面的新代码:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("Selected_PC")) Is Nothing Then

    If Range("Selected_PC").Value = "S&S - Marine" Then
        MsgBox "Please be aware, for this profit center the template will not produce a result for the Underwriter assignment. If an Underwriter sent in the submission refer to that Underwriter."

    End If
End If
End Sub

代码放置是我的问题。我最初试图将代码添加到我的模块中,在该模块中为“ Selected_PC”创建了用户定义的函数。我将代码移到了目标单元所在的工作表中。这似乎可以解决问题。菜鸟通过调用模块中的工作表更改来进行移动...实时学习,我猜。谢谢大家的帮助!

0 个答案:

没有答案