OzGrid

How to create Excel VBA code to ascertain if cell value is greater than 2 cell values, show a pop up message box

< Back to Search results

 Category: [Excel]  Demo Available 

How to create Excel VBA code to ascertain if cell value is greater than 2 cell values, show a pop up message box

 

Requirement:

 

The user wants a message box to pop up if the value in cell F19 is > than the value in cell 011. If so, the message should be "IUT is too large for Reference 1".

If not, then it should check to see if the value in cell F19 is > than the value in cell R11. If so, the message should be "IUT is too large for Reference 2".

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/149659-excel-vba-code-if-cell-value-is-greater-than-2-cell-values-show-a-pop-up-message-box

 

Solution:

 

Code:
Sub TestMsg()

If Range("F19") > Range("O11") Then
    MsgBox "IUT is too large for Reference 1"
ElseIf Range("F19") > Range("R11") Then
    MsgBox "IUT is too large for Reference 2"
End If

End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by Carim.

 

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 set up a pop up message when sum of columns exceeds X
How to bring an excel userform message box above all other windows
How to create a pop up message if the length exceeds the limits
How to display a message for each if the value is greater than the mentioned values

 

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)