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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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