ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to create msg box if a cell contains value < 0 (https://www.excelbanter.com/excel-programming/404477-how-create-msg-box-if-cell-contains-value-0-a.html)

ghost

How to create msg box if a cell contains value < 0
 
Greeting,
I have a column has 5 cells which they have function (sum) depend on other
cells. In those cells I what to make a msgbox warns the user that the value
of one of them or all is under 0 and the user should input other data . i.e.
if E1 has the value of sum A1and B1, a msg box appears and warns.
how can I do that?

Per Jessen[_2_]

How to create msg box if a cell contains value < 0
 
On 17 Jan., 20:52, ghost wrote:
Greeting,
I have a column has 5 cells which they have function (sum) depend on other
cells. In those cells I what to make a msgbox warns the user that the value
of one of them or all is under 0 and the user should input other data . i.e.
if E1 has the value of sum A1and B1, a msg box appears and warns.
how can I do that?


Hi

Insert the code in the code-sheet for the desired sheet.

Private Sub Worksheet_Calculate()
If Range("E1") < 0 Then
MsgBox ("Error")
End If
End Sub

//Per

Rick Rothstein \(MVP - VB\)

How to create msg box if a cell contains value < 0
 
The problem I see with a message box solution is as soon as the message box
was dismissed, it would pop up again giving the user no time to act. How
about this instead. Select the five cells; click
Format/ConditionalFormatting from Excel's menu; select "Cell Value Is" from
the first field, "less than" from the second field, put 0 into the third
field; click the Format button; click the Font tab and select Bold from the
"Font style" field and White from the Color drop down; click the Patterns
tab and pick a dark red color from the Color grid; then OK your way back to
the spread sheet. Now, if any of these cells fall below zero, they will be
highlighted in the color with the font style you just picked.

Rick


"ghost" wrote in message
...
Greeting,
I have a column has 5 cells which they have function (sum) depend on other
cells. In those cells I what to make a msgbox warns the user that the
value
of one of them or all is under 0 and the user should input other data .
i.e.
if E1 has the value of sum A1and B1, a msg box appears and warns.
how can I do that?




All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com