如果字符串中包含特定值则显示 MsgBox,然后清除单元格

Show MsgBox if contains a certain value within a string and then clear the cell

我在单元格 C11 中有一个 select 货币对的下拉菜单(下面的屏幕截图)。我想编写一个宏,当用户 select 是 7 个日语对之一时生成 MsgBox。最好是,我想要一个代码来检查单元格是否包含值 "JPY"s,然后消息框应该询问:

"You have selected a Japanese Yen cross, do you want to continue?"

然后,我希望用户能够:

谢谢。

尝试将以下内容放在 sheet 下拉列表所在的位置

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ans As VbMsgBoxResult

If Not Intersect(Target, Range("C11")) Is Nothing Then
    If InStr(Target, "JPY") Then
        ans = MsgBox("You have selected a Japanese Yen cross, do you want to continue?", vbYesNo)

        If ans = vbNo Then
            Application.EnableEvents = False
                Target.Clear
            Application.EnableEvents = True
        End If
    End If
End If

End Sub