Ashley wonders how to limit the input of a number to 2 decimal places. In trying to figure it out, she notes that the Data Validation tool does not seem to work for this requirement.

There are two ways you can approach this problem. The first is to use a custom rule in Excel's Data Validation tool. Follow these steps:

- Select the cell where you want to limit the input to two decimal places. (For this example, let's assume you select cell A1.)
- Display the Data tab of the ribbon.
- Click the Data Validation tool. Excel displays the Data Validation dialog box.
- Make sure the Settings tab is displayed. (See Figure 1.)
- In Allow drop-down list, choose Custom.
- In the Formula box (which appears when you complete step 5), enter the following formula:

** Figure 1.** The Settings tab of the Data Validation dialog box.

=MOD(A1*100,1)=0

This validation formula works because it checks to make sure that the value in A1, when multiplied by 100 and then divided by 1, has no remainder. It will only have this remainder if there are three or more decimal places in the value entered. Validation will also fail if someone tries to enter text into cell A1.

There are, of course, any number of other formulas you could use in step 6. Here are a few:

=INT(A1*100)=(A1*100) =A1=ROUND(A1,2) =ABS(A1-ROUND(A1,2))<1E-8 =FIND(".",A1,1)>=LEN(A1)-2

Instead of using Data Validation, there is another approach you could take. This one involves using the following steps:

- Select the cell where you want to limit the input to two decimal places. (For this example, let's assume you select cell A1.)
- Format the cell as desired, but make sure it is at least formatted to display only two decimal places.
- Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 and later versions display the File tab of the ribbon and then click Options.)
- Click the Advanced option at the left of the dialog box.
- Scroll through the available options until you see the When Calculating This Workbook section. (See Figure 2.)
- Ensure that the Set Precision as Displayed check box is selected.
- Click OK.

** Figure 2.** The Advanced options of the Excel Options dialog box.

Now, when someone enters a value into the cell you formatted in step 2, it will be rounded to two decimal places automatically, and Excel will make sure that any calculations use the two-decimal-place value.

The drawback to this approach is that changing how Excel does its calculations (steps 3 through 6) affects the entire workbook, not just the data-entry cell selected in step 1. If this is unacceptable to you, then you should definitely choose the Data Validation approach, discussed earlier.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (889) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365.

**Create Custom Apps with VBA!** Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out *Mastering VBA for Office 2013* today!

When creating a worksheet, you may need to limit what can be entered into a particular cell. Using data validation you ...

Discover MoreThe Data Validation capabilities of Excel can be very helpful when you are trying to control what people can enter into a ...

Discover MoreData validation allows you to create drop-down lists that aid data entry. If you want the indicator for the drop-down ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2019-07-17 13:36:06

John Lute

I've modified this to =FIND(".",A1,1)>=LEN(A1)-4 in order to limit to four decimal places. The trouble with EITHER of these is that whole numbers won't match the validation. For example, 523.00 or 523.000 throw validation errors.

Any idea how to handle these?

2019-07-17 12:29:08

John Lute

I've modified this to =FIND(".",A1,1)>=LEN(A1)-4 in order to limit to four decimal places. The trouble with EITHER of these is that whole numbers won't match the validation. For example, 523.00 or 523.000 throw validation errors.

Any idea how to handle these?

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2020 Sharon Parq Associates, Inc.

## Comments