Need Msgbox to only appear once when specific cell changes

Posted on 2012-09-06
Last Modified: 2012-09-06
I have a validation box with a list in it and I just want a msg box to show when the user selects "CAB Rating - Dangerous" from the dropdown.  All the If statements, and case ranges make the msgbox appear with every cell that is selected, not just when cell b5 changes.  What am i missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("B5").Value
     Case "CAB Rating - Dangerous"
         MsgBox "Referral is Required for Cab Ratings of Dangerous"

     Case Else
End Select

End Sub
Question by:kateebebe
    LVL 92

    Accepted Solution

    If you only want to fire something when B5 changes then you're using the wrong event.  Instead:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, [b5]) Is Nothing Then
            If [b5] = "CAB Rating - Dangerous" Then
                MsgBox "Referral is Required for Cab Ratings of Dangerous"
            End If
        End If
    End Sub

    Open in new window


    Author Closing Comment

    Thanks!! Originally I had multiple "cases" and then it went down to one.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Vlookup for IP 3 36
    Excel line breaks 1 19
    recovering Excel 2016 file 2 25
    Removing text between BBCODE tags in Excel 3 33
    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now