VBA for Message Box Upon Active Cell Value

nc_waggoner

New Member
Joined
Sep 2, 2016
Messages
21
I have a file with drop downs. The goal is to remind users to enter a response in column K (root cause) if the option "Employee Error" is chosen from the drop down in column H (Cause). How do I make a message box appear saying "Please enter a root cause" once a user chooses "Employee Error" in the drop down? I have tried:

Sub RootCause()

IF ActiveCell.Value = "Employee Error" Then
MsgBox ("Please enter a root cause")

End If
End Sub

However, the message box will not pop up. Thanks for the help!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
You need a worksheet change event macro - not a standard macro if you want an automatic pop up.

Put the code below in the worksheet that has your drop downs following the steps below:
To install the code:
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 below 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.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H:H")) Is Nothing Then
    If LCase(Target.Value) = "employee error" Then
        If Not IsEmpty(Target) And IsEmpty(Target.Offset(0, 3)) Then
            MsgBox "Please enter a root cause in cell: " & Target.Offset(0, 3).Address(0, 0)
            Target.Offset(0, 3).Select
        End If
    End If
End If
End Sub
 
Upvote 0
Joe, that did not seem to work. I followed the steps and the code looks fine. Saved it as XLSM, macros are enabled. But when I chose that option from the drop down in Column H, nothing happened.
 
Upvote 0
Joe, that did not seem to work. I followed the steps and the code looks fine. Saved it as XLSM, macros are enabled. But when I chose that option from the drop down in Column H, nothing happened.
Did you choose the specific option "Employee Error" per your OP? If yes, you may have inadvertently disabled events. To fix that open your workbook to the sheet with the code. Then press alt + F11 keys to open the VBE window. Press ctrl + g keys to open the Immediate Window, then in the Immediate Window type (w/o the quote marks) "Application.EnableEvents = True" and press enter.

Now change a cell in col H that has an empty cell in col K - use the drop down in col H and select "Employee Error" and you should see the pop up. If not you have most likely not installed the code correctly or your trust center settings disable all macros w/o warning.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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