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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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