OzGrid

How to create a pop-up message if the length exceeds the limits

< Back to Search results

 Category: [Excel]  Demo Available 

How to create a pop-up message if the length exceeds the limits

 

Requirement:

 

The user has 2 values for cell B8, which gives a result in F5.  If cell B8 = 9, cell F5 must be <720 and if cell B8 = 11, cell F5 must be < 780.
 
The user is working with aluminium. The size of aluminium in B8 determents the length used in F5 (value in F5). The user has got a formula for that, but needs a pop-up message if the length exceeds the limits as in previous mentioned above. The user does have a message, but it is only for one condition:

Private Sub Worksheet_Calculate()

If Range("F5").Value > 720 Then
MsgBox "Maximum H/S Size Limit for R11 = 780mm and for R9 = 720mm"
End If

End Sub

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1201612-2-cell-values-and-1-result

 

Solution:

 

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A7") = 9 And Range("F5") > 720 Then
    MsgBox "Maximum H/S Size Limit for R9 = 720mm", vbCritical, ""
ElseIf Range("A7") = 11 And Range("F5") > 780 Then
    MsgBox "Maximum H/S Size Limit for R11 = 780mm", vbCritical, ""
End If

End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by chirayuw.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to create excel VBA code to ascertain if cell value is greater than 2 cell values, show a pop up message
How to use InputBox to populate function
How to check values in a column and if condition matches then populate 3 other columns.
How to end a macro if cell blank or continue if populated

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)