How to create msg box if a cell contains value < 0

G

ghost

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?
 
P

Per Jessen

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
 
R

Rick Rothstein \(MVP - VB\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top