Unreal1998
asked on
Excel Message Box dependent on cell value
I have a list on cell B3 and I want a message to appear every time a certain value is selected. For example:
On cell value change
IF B3="JUSTIN B" then show message "RUN FOR YOUR LIFE!"
Lastly, can I duplicate this macro for multiple cell values and show other messages.
For example:
IF B3="JUSTIN B" then show message "RUN FOR YOUR LIFE!"
IF B4="Y" then show message "Complete Question on Cell G7!" And so forth...
On cell value change
IF B3="JUSTIN B" then show message "RUN FOR YOUR LIFE!"
Lastly, can I duplicate this macro for multiple cell values and show other messages.
For example:
IF B3="JUSTIN B" then show message "RUN FOR YOUR LIFE!"
IF B4="Y" then show message "Complete Question on Cell G7!" And so forth...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's not the SelectionChange but Change event which you need, otherwise the test and message will pop up every time any cell is selected.
In my code, it is also checked whether one of the trigger cell is changed, a necessary condition.
In my example, I have showed 2 empty conditions, for you to play around and extend.
In my code, it is also checked whether one of the trigger cell is changed, a necessary condition.
In my example, I have showed 2 empty conditions, for you to play around and extend.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The MsgBox spawning message was intended for javatper's code, not calacuccia's. Calacuccia's seems to be pretty much like mine, only I'd like to think that my If statements are prettier :D
Other event my friend :-)
Actually, I wanted Worksheet_Change too, cause that's what makes sense. I had assumed javatper's was that one and I copied/pasted without noticing :P
Oops.. Misread the question and went off and did my own thing. Ignore.
Matt
Matt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great! Too bad I could not give 500 points to all.
Private Sub Worksheet_SelectionChange(
If Range("B3").Value = "JUSTIN B" Then
MsgBox "RUN FOR YOUR LIFE!"
End If
If Range("B4").Value = "Y" Then
MsgBox "Complete Question on Cell G7!"
End If
End Sub