Prevent Negative Numbers in a column

manubhanot

New Member
Joined
Mar 6, 2018
Messages
7
Greetings to all! I just joined this forum so that I can learn from the experts and contribute as much as I can.

I have a situation for which I am looking a solution for:

I have three sheets in my excel file to manage inventory, namely, Demand, Supply, Inventory. Let us say that an article in Cell A2 in "Demand" = 5 and the same cell in "Supply" = 7; so we should be ok (because we have more than what is being demanded). Cell C2 in Inventory will show +2 (7 minus 5) as 2 items will be left after delivering 5.

I would want some formula that will help me restrict negative entries. Let me explain: Let us say that an article in Cell A2 in "Demand" = 7 and the same cell in "Supply" = 5. This would mean that a negative numbers will appear in Cell C2 of "Inventory" sheet. (because we have less than what is being demanded). I would want to put some kind of validation so that I can prevent this from happening.

Thanks in advance.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi,

Formula references are based on my sample below, adjust to your data.

In Cell A4, Data Validation, Custom, enter formula as shown in D4, select Error Alert tab, enter error message as you wish (something like: Value entered Exceeds current Supply)


Book1
ABCD
1DemandSupplyInventory
2572
375-2
455TRUE
525TRUE
665FALSE
Sheet11
Cell Formulas
RangeFormula
C2=B2-A2
D4=A4<=B4
 
Last edited:
Upvote 0
Assuming C2 is calculated using a formula like:
=Supply!C2-Demand!C2
what would you want the formula in Inventory cell C2 to return if the above formula returns a negative number?
 
Upvote 0
Hello! Thanks for the reply, but unfortunately this does not suit my purpose. Demand, Supply and Inventory are in three different tabs of my excel file. The objective is to stop the user from entering anything in the demand file if the resultant is a negative number in the inventory file.

==============================================================
Hi,

Formula references are based on my sample below, adjust to your data.

In Cell A4, Data Validation, Custom, enter formula as shown in D4, select Error Alert tab, enter error message as you wish (something like: Value entered Exceeds current Supply)

ABCD
1DemandSupplyInventory
2572
375-2
455TRUE
525TRUE
665FALSE

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet11

Worksheet Formulas
CellFormula
C2=B2-A2
D4=A4<=B4

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Assuming C2 is calculated using a formula like:
=Supply!C2-Demand!C2
what would you want the formula in Inventory cell C2 to return if the above formula returns a negative number?


The objective is to stop the user from entering anything in the demand file if the resultant is a negative number in the inventory file.
 
Upvote 0
You could use Data Validation (DV) in column C of the Demand sheet. The DV formula would be:
Code:
=Supply!$C2-$C2>=0
Alternatively, you could use a worksheet_change event module in the Demand sheet. If that's of interest, let me know.
 
Upvote 0
Hello! Thanks for the reply, but unfortunately this does not suit my purpose. Demand, Supply and Inventory are in three different tabs of my excel file. The objective is to stop the user from entering anything in the demand file if the resultant is a negative number in the inventory file.

==============================================================

That is EXACTLY what that Data Validation will do. Whenever anyone tries to enter a value in Demand A2 that is Greater than Supply, it will be rejected, and the Error Message will pop up letting the User know that it exceeds the Supply, thus, Inventory will never be Negative.

Have you tried it???

As I said, adjust formula to your data, something like this:

Code:
=A2<=Supply!B2

Put that formula in your Demand sheet subject cell (where user enters the number for Demand), reference your Supply sheet cell where you store your amount for Supply.
 
Upvote 0
Do I need to put this formula for every cell in the sheet or can I use a generic formula for the column?
 
Upvote 0
That is EXACTLY what that Data Validation will do. Whenever anyone tries to enter a value in Demand A2 that is Greater than Supply, it will be rejected, and the Error Message will pop up letting the User know that it exceeds the Supply, thus, Inventory will never be Negative.

Have you tried it???

As I said, adjust formula to your data, something like this:

Code:
=A2<=Supply!B2

Put that formula in your Demand sheet subject cell (where user enters the number for Demand), reference your Supply sheet cell where you store your amount for Supply.

I applied this formula successfully for the column
=$F2<=INVENTORY!$D2

Is there a way to increase the range in the formula; something like:
=($F2:R2)<=INVENTORY!$D2
 
Upvote 0
If it's only Column F and Column R, I would enter it separately, just like the way you did Column F.
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

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