Conditional pop up window

eh_wanna_wanga

New Member
Joined
Dec 1, 2015
Messages
5
Hi all,

Been looking around the webs trying to find some script that i can alter for my needs but haven't had any luck...

i have been trying to get a pop up message window to display if a certain value is selected in a drop down, e.g if "unknown" is selected message window displaying "Invalid selection, you idiot"

i know it sounds simple, and it probably is... but for the life of me i just cant seem to get it working how i want.

any help would be much appreciated, even if there are just any more examples that will give a similar outcome that i can work from.

Thanks,
E.W.W
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You will improve your chance of getting some help by telling us what cell(s) the drop down(s) is/are in and what kind of drop down it is - validation, forms control (list box, combo box), or active-x control (list box, combo box).
 
Upvote 0
Sorry joe, details are as follows,

drop is just Data Validation, drop downs are in column F so range would be $F:$F, and trigger would be "unknown"
 
Upvote 0
Sorry joe, details are as follows,

drop is just Data Validation, drop downs are in column F so range would be $F:$F, and trigger would be "unknown"
This is event code for the worksheet - not a standard module.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Columns("F")) Is Nothing Then
    For Each c In Intersect(Target, Columns("F"))
        If LCase(c.Value) = "unknown" Then
            MsgBox "Invalid selection, you idiot - try again"
            Application.EnableEvents = False
            Application.Undo
            Application.EnableEvents = True
            Exit Sub
        End If
    Next c
End If
End Sub
 
Upvote 0
ok so please ignore that last question, im not sure what to select for the right drop down above the code window, would it be SelectionChange?
 
Upvote 0
ok so, ive added this to the worksheet as change, and its not doing anything... pretty sure im not doing anything obviously wrong code just dosnt seem to be working, can anyone else lend a hand?
 
Last edited:
Upvote 0
ok so, ive added this to the worksheet as change, and its not doing anything... pretty sure im not doing anything obviously wrong code just dosnt seem to be working, can anyone else lend a hand?
You haven't installed the code correctly or you have managed to disable events.

To install the code (after deleting whatever you have already installed):
1. Right-click the worksheet tab you want to apply it to and choose 'View Code'. This will open the VBE window.
2. Copy the code from your browser window and paste it into the white space in the VBE window.
3. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
4. Make sure you have enabled macros whenever you open the file or the code will not run.

While you have the VBE window open, press ctrl + G to open the immediate window, then type:
Application.EnableEvents = true
and press Enter.

Now things should work.
 
Upvote 0

Forum statistics

Threads
1,215,560
Messages
6,125,523
Members
449,236
Latest member
Afua

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