?
Solved

Need Msgbox to only appear once when specific cell changes

Posted on 2012-09-06
2
Medium Priority
?
668 Views
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
0
Comment
Question by:kateebebe
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 38374134
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

0
 

Author Closing Comment

by:kateebebe
ID: 38374185
Thanks!! Originally I had multiple "cases" and then it went down to one.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

840 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