Msg Box appears when "Yes" is entered into a cell in a range

camjamco

New Member
Joined
Feb 18, 2019
Messages
9
When someone enters "Yes" into any cell in Column C I have it set to conditional format in red to highlight it however I would also like a text box to appear saying "You have identified this as a risk, please enter more details into column X".

I have tried a few different macros on different forums but I cant get it to work :(
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi. See if this works. Right click on sheet tab, press view code and paste in the below:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range, c As Range

Set rng = Intersect(Target, Columns("C"), ActiveSheet.UsedRange)
If Not rng Is Nothing Then
    For Each c In rng
        If LCase(c) = "yes" Then
            MsgBox "You have identified this as a risk, please enter more details into column X"
            Exit For
        End If
    Next
End If
    
End Sub
 
Upvote 0
That didnt work, when I type in yes in C19 the conditional formatting runs but not the message box.

I have a little exposure to macros but not a lot so just to clarify after clicking view code I am copying it straight into the sheet rather ThisWorkbook
 
Upvote 0
Just one quick last question,

In column F I have a name, for the message is it possible to have the message as

"You have identified "Name" as a risk, please enter more details into column X"
 
Upvote 0
You can just add another test:

Code:
Set rng = Intersect(Target, Columns("C"), ActiveSheet.UsedRange)
If Not rng Is Nothing Then
    For Each c In rng
        If LCase(c) = "yes" Then
            If Len(c.Offset(0, 3)) > 0 Then
                MsgBox "You have identified " & c.Offset(0, 3) & " as a risk, please enter more details into column X"
            Else
                MsgBox "You have identified this as a risk, please enter more details into column X"
            End If
            Exit For
        End If
    Next
End If
 
Upvote 0
Im not sure what I have now done as I tried using that and it didnt work so tried to revert it back to just the original code and now that isnt working either

Sorry! :(
 
Upvote 0
I dont know what isnt working means. What is happening? Heres the instructions again. Go to the sheet where you want the macro to run. Right click on the sheet tab. Press view code. Paste in this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range, c As Range

Set rng = Intersect(Target, Columns("C"), ActiveSheet.UsedRange)
If Not rng Is Nothing Then
    For Each c In rng
        If LCase(c) = "yes" Then
            If Len(c.Offset(0, 3)) > 0 Then
                MsgBox "You have identified " & c.Offset(0, 3) & " as a risk, please enter more details into column X"
            Else
                MsgBox "You have identified this as a risk, please enter more details into column X"
            End If
            Exit For
        End If
    Next
End If

End Sub

Close the window. In the sheet enter yes into a cell in column C. Provided there is something in column F of the same row you will get the new message box provided macros are enabled within the workbook.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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