Limit Sales Quantity Within Stock in Google Sheets

Published on

Running into negative inventory in Google Sheets is more common than you might think. One of the main reasons? Entering sales quantities that are bigger than what you actually have in stock.

The good news is: with data validation, you can easily make sure you never sell more than what’s available, saving time and preventing errors. This trick is especially handy for traders, wholesalers, and inventory managers.

Why You Should Limit Sales Quantity

Let’s say you have this situation:

  • Available stock for Item 1: 100 MT
  • Customer A orders: 60 MT
  • Customer B orders: 50 MT

If you enter both orders as-is, the total (110 MT) goes over your stock—and suddenly, you have negative inventory.

With data validation, Google Sheets can automatically restrict the second order to only 40 MT, keeping your total at 100 MT.

When you have multiple items and customers, manually tracking stock gets messy. This method keeps everything accurate without constantly checking your numbers.

Setting Up Data Validation in Google Sheets

Here’s the setup we’ll use:

  1. Stock Table (Sheet1) – where all purchases are recorded
  2. Sales Table (Sheet2) – where sales orders are entered

Our goal: limit sales entries in the Sales Table based on available stock in the Stock Table.

Stock Table Examples

Google Sheets stock table showing item codes, item names, and available quantities for inventory management

Note: Whether an item has a single stock entry or multiple entries, the validation rule works the same way.

Sales Table Example

For example, the total stock of Road Base (RB01) is 150 MT. The rule will prevent Customer B from entering more than 80 MT (150 – 70).

Google Sheets sales table showing customer orders and quantities with data validation to limit sales within stock

The Data Validation Formula

Here’s the custom formula to make this work:

=SUMIF($A$2:$A, A2, $C$2:$C) <= SUMIF(Sheet1!$A$2:$A, A2, Sheet1!$C$2:$C)

How to Apply It

  1. Select the Quantity column in your Sales Table (e.g., C2:C).
  2. Go to Data → Data Validation.
  3. Click Add Rule.
  4. Under Criteria, choose Custom formula is.
  5. Paste the formula above.
  6. Select Reject input for invalid entries.
  7. Click Done.

Now, any attempt to enter a quantity that exceeds stock will be blocked automatically.

How This Formula Works

The formula uses two SUMIF functions:

  • SUMIF($A$2:$A, A2, $C$2:$C) → sums all sales quantities for the item.
  • SUMIF(Sheet1!$A$2:$A, A2, Sheet1!$C$2:$C) → sums all available stock for the same item.

It only allows an entry if total sales ≤ stock.
Relative references ensure it works for each row automatically.

Benefits of Using Data Validation

  • Prevents negative inventory automatically
  • Reduces errors when entering sales data
  • Works for items with single or multiple stock entries
  • Easy to maintain for multiple products and customers

Related Tutorials

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.