Tennisguuy
Well-known Member
- Joined
- Oct 17, 2007
- Messages
- 564
- Office Version
- 2016
- Platform
- Windows
I am trying to create a pop up window with VBA code. I am not good with VBA code but found some things on line but it's not working. I want to have a pop up window display a message once if the value in F7 equals a certain value and if possible have it only popup again if the value in F7 changes and meet another criteria.
This is the code I have but it not working.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F7:F7")) Is Nothing And _
If Range("F7").Value =1 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =2 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =3 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =4 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =5 Then MsgBox "A RISK SCORE OF 5 IS TYPICALLY 0% TO 5% LOWER THAN YOUR AVERAGE RISK IN YOUR DATA"
If Range("F7").Value =6 Then MsgBox "RISK SCORE OF 6 IS 0% TO 7.5% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =7 Then MsgBox "RISK SCORE OF 7 IS 7.5% TO 15% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =8 Then MsgBox "RISK SCORE OF 8 IS 15% TO 25% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =9 Then MsgBox "RISK SCORE OF 9 IS 20% TO 25% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =10 Then MsgBox "RISK SCORE OF 10 IS 25% TO 30% MORE HIGHER THAN YOUR AVERAGE RISK"
End If
End Sub
This is the code I have but it not working.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F7:F7")) Is Nothing And _
If Range("F7").Value =1 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =2 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =3 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =4 Then MsgBox "RISK SCORE OF 1 IS 20% OR MORE LOWER THAN YOUR AVERAGE RISK"
If Range("F7").Value =5 Then MsgBox "A RISK SCORE OF 5 IS TYPICALLY 0% TO 5% LOWER THAN YOUR AVERAGE RISK IN YOUR DATA"
If Range("F7").Value =6 Then MsgBox "RISK SCORE OF 6 IS 0% TO 7.5% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =7 Then MsgBox "RISK SCORE OF 7 IS 7.5% TO 15% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =8 Then MsgBox "RISK SCORE OF 8 IS 15% TO 25% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =9 Then MsgBox "RISK SCORE OF 9 IS 20% TO 25% MORE HIGHER THAN YOUR AVERAGE RISK"
If Range("F7").Value =10 Then MsgBox "RISK SCORE OF 10 IS 25% TO 30% MORE HIGHER THAN YOUR AVERAGE RISK"
End If
End Sub