当某个单词input到单元格中时,在Excel中popup消息

我试图创build一个popup式消息,只有在某个单词出现在电子表格的一个单元格区域时才会出现。 目前我写的macros显示popup信息,只要input任何内容。 这里是我有的代码:

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 

再次,我只想popup单词DURA-CORE II出现在单元格的范围。 现在我会承认我几乎不了解VBA,所以我相信这个解决scheme非常简单。

任何帮助表示赞赏。

像这样的东西?

 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 

通过这种方式,只要Range("G10:G40")任何单元格的内容为“DURA-CORE II”