A resource for users and developers of Microsoft Excel |
|||||||||
| Email us your FAQ suggestion. |
|||||||||
Visit often ! Pages are updated daily. |
|||||||||
This is the Excel "How to" Frequently Asked Questions page |
|||||||||
Answers to Frequently Asked Questions about how to do common tasks in Microsoft Excel. |
|||||||||
Excel "How to" FAQs |
| How to limit how many characters can be entered in a cell? |
| Example |
If you are entering a list of values that are meant to be of a certain length, such as postal codes or zip codes, you would want to only allow entries that are of a specific string length. An example is United States zip codes, because you would want entries that are 5 digits (for this example we are not considering the hyphenated four-digit extension that has never quite caught on). Data Validation can be used to mandate character length, and that each character is a number, in this example entries being made in range A2:A20. Select range A2:A20 and then... In Excel version 2003 or before: In Excel version 2007: In the Data Validation dialog where you would be now, from the Allow drop down list, select Text length; from the Data drop down list, select Equal to; and in the Length field, enter 5. As a side note, some zip codes begin with a leading zero so beforehand, format the range as Text. To deal with the possibility of an entry where one or more characters is not a number, and you still want to allow for a leading zero, a custom formula would help. Select range A2:A20. In the Allow drop down list, select Custom, and in the formula field enter Click onto the Input Message tab to enter optional text, such as entry instructions, that will appear when the user selects that cell.
|