VBA Pop up message

jbsin89

New Member
Joined
Mar 29, 2018
Messages
2
Hi all,

Hope someone will be able to help. I am below beginner with VBA and what I'm trying to do is starting to frustrate.

I have a form for a customer to complete. When a number < 5 is entered into a specific cell I need a pop up to come up saying "Please provide key improvement"

This would then would need to be applied down the table (AF20:AF30)

Is someone able to point me in the right direction?

Thanks

J
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi.

Right click on your sheet tab and click view code.
In the vba editor that appears, paste this code :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    On Error Resume Next
    Dim rng As Range
    Set rng = Intersect(Target, Range("AF20:AF30"))
    
    If rng Is Nothing Then Exit Sub
    On Error GoTo 0
    
    Dim c As Range
    
    For Each c In rng
        
        If c.Value < 5 Then
            MsgBox "Cell " & c.Address & " : Please provide key improvement."
        End If
        
    Next c

End Sub
 
Upvote 0
Are you saying if a value less then 5 is entered in Range("
AF20:AF30") then you want the message box to pop up?

If this is not what you want then please explain more please.

You used the term Form and Table so I may be confused.


 
Upvote 0
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("AF20:AF30")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value < 5 Then MsgBox "Cell " & Target.Address & " : Please provide key improvement."
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,803
Members
449,190
Latest member
cindykay

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