New Tool Radar

AI for Data & Spreadsheets

How to Set a Data Validation Rule for Decimal Places in Excel

Add a data validation rule in Excel that only accepts numbers with at most two decimal places.

Schematic illustration for How to Set a Data Validation Rule for Decimal Places in Excel: three numbered steps - Select the amount column; Data Validation, Custom formula; Test a three-decimal value.

A price typed with three decimal places will round differently in different parts of a workbook, and the totals will drift by pennies. A custom validation formula that rejects more than two decimal places stops the problem at entry, before any total is built on it.

Prerequisites

  • Excel
  • A column that should hold amounts with at most two decimal places
  • A copy of the source file, so the original stays untouched.

Steps

  1. Select the amount column, then go to Data, Data Validation.
  2. Set Allow to Custom, and enter a formula that checks the value, such as =A2=ROUND(A2,2), adjusted to the first cell.
  3. Set the error alert to Stop, with a message that explains the two-decimal rule.
  4. Click OK, then test the rule by typing a value with three decimal places and confirming it is refused.
  5. Check the existing values in the column for any that already carry more than two decimals.

Worked example: Fictional prices with a two-decimal rule

The practice table below is a fictional five-item price list. Each amount has two decimal places, and the total is their sum. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.

Item Amount
Notebook 6.49
Pen set 9.95
Stapler 12.50
Tape dispenser 5.25
Desk lamp 24.99
Total 59.18

Expected result. Five prices, each with two decimal places, and the amounts add to 59.18.

Limits

  • A custom formula must be written for the first cell of the range, or it will check the wrong cell.
  • A pasted range can bypass validation, so check pasted data after import.

Sources

See all