VBA code for message box (pop-up)

jgopalk

New Member
Joined
Jun 14, 2011
Messages
26
Hi,

I have few cells where "Yes" or "No" to be selected from drop down. When the selection is "Yes" I need message box to pop-up. Likewise there are around 7 cells with 7 different message to pop-up in message box.

E.g.,

A1 = Yes "Msg 1"
A2 = Yes "Msg 2"

Likewise for 7 cells. If "NO" no pop-up is required.

Please let me know how to include all 7 cells in this code (with 7 different messages).

Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this code in the resulting VB Editor window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Count > 1 Then Exit Sub
    
    Select Case Target.Address(0, 0)
        Case "A1"
            If Target = "Yes" Then MsgBox "You updated cell A1"
        Case "A2"
            If Target = "Yes" Then MsgBox "You updated cell A2"
        Case "A3"
            If Target = "Yes" Then MsgBox "You updated cell A3"
        Case "A4"
            If Target = "Yes" Then MsgBox "You updated cell A4"
        Case "A5"
            If Target = "Yes" Then MsgBox "You updated cell A5"
        Case "A6"
            If Target = "Yes" Then MsgBox "You updated cell A6"
        Case "A7"
            If Target = "Yes" Then MsgBox "You updated cell A7"
    End Select

End Sub
Change your messages to your liking.
 
Last edited:
Upvote 0
You are welcome.
Glad I was able to help!:)
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top