Excel Negative Value Warning

bmpreston

Board Regular
Joined
Jun 18, 2016
Messages
120
Office Version
  1. 365
Platform
  1. MacOS
Hello,

I'm working on a primitive inventory sheet and came across this:

https://www.mrexcel.com/forum/excel-questions/141057-negative-value-pop-up-warning.html

From here:

Private Sub Worksheet_Calculate()
For Each cell In Range("B5:B16")
If cell.Value < 0 Then MsgBox ("Warning: Negative value!."), , "Invalid Entry"
Next cell
End Sub
This works well, except, if I use a separate worksheet to alter the data, it locks me in a permanent Message Box, even had to Force Quit to get it out. lol.

I need just a single pop up on evaluation.

Any help?

Thanks
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You could use validate - it's on the data tab - highlight the column where you want only positive values and select data validation
 
Upvote 0
I couldn't seem to get that to work. The data is actually a formula and is never directly entered. It is a simple math problem of on hand minus used parts plus new delivery. If the total is less than zero, explain yourself....

Thanks
 
Upvote 0
Here's a tutorial on validation: https://www.excel-easy.com/basics/data-validation.html
Since you're using a formula to create the field, you could put another layer in it:
Code:
=IF([B]your current formula[/B] < 0,"Negative not allowed",[B]your current formula[/B])

FYI - I've run into Excel hanging with Worksheet_Calculate(). I wonder if activating the worksheet containing your target range just prior to the For.. Next.. would work.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top