Vba 将特定单词输入单元格时Excel中的弹出消息

Vba 将特定单词输入单元格时Excel中的弹出消息,vba,excel,Vba,Excel,我正在尝试创建一个弹出消息,该消息仅在某个单词出现在电子表格的某个单元格区域时才会出现。当前,无论何时输入任何内容,我编写的宏都会显示弹出消息。以下是我的代码: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("G10:G40")) Is Nothing Then MsgBox "Exact dimensions needed for ceramic pi

我正在尝试创建一个弹出消息,该消息仅在某个单词出现在电子表格的某个单元格区域时才会出现。当前,无论何时输入任何内容,我编写的宏都会显示弹出消息。以下是我的代码:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("G10:G40")) Is Nothing Then
        MsgBox "Exact dimensions needed for ceramic pipe due to required shop fabrication.  This can affect both pipe costs and leadtime."
    End If
End Sub
同样,我只希望当单词DURA-CORE II出现在单元格范围内时出现弹出窗口。我现在要承认,我对VBA几乎一无所知,所以我确信修复方法相当简单

非常感谢您的帮助。

像这样的吗

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("G10:G40")) Is Nothing Then
        If Target = "DURA-CORE II" Then
            MsgBox "Exact dimensions needed for ceramic pipe due to required shop fabrication.  This can affect both pipe costs and leadtime."
        End If
    End If
End Sub
你可以用

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Range("G10:G40").Find(what:="DURA-CORE II", LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True) Is Nothing Then
        MsgBox "Exact dimensions needed for ceramic pipe due to required shop fabrication.  This can affect both pipe costs and leadtime."
    End If
End Sub

通过这种方式,只要
范围(“G10:G40”)
中的任何单元格有“DURA-CORE II”内容,就会始终通知用户,因此,如果在第一个单元格中,请放置另一个单元格<代码>如果Target.Value=“DURA-CORE II”,则此操作非常有效!感谢您帮助一位非常非常新手的VBA用户。欢迎您。然后,您可能希望通过单击答案旁边的复选标记将我的答案标记为已接受,以将其从灰色切换为已填写。非常感谢。