Share via

I need to limit the number of characters in a single cell to 255 in a template used by my company. Is there a way to do this?

Anonymous
2016-09-29T16:46:29+00:00

I have set up a template that is used to auto-import data into a database. One of the fields have 255 character limitation in the database, so I need to have something that restricts - or at least notifies the user - that the character limit has been exceeded.

Is there a way to do this?

TIA!

MacCupcake

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2016-09-29T18:18:18+00:00

    Hi, data validation

    Restrict data entry to text of a specified length

    1. Select one or more cells to validate.
    2. On the Data tab, in the Data Tools group, click Data Validation.

    Issue: The Data Validation command is unavailable.

    An Excel table may be linked to a SharePoint site   You cannot add data validation to an Excel table that is linked to a SharePoint site. To add data validation, you must unlink the Excel table or convert the Excel table to a range.

    You may be currently entering data   The Data Validation command is not available on the Data tab while you are entering data in a cell. To finish entering, press ENTER or ESC.

    The worksheet might be protected or shared   You cannot change data validation settings if your workbook is shared or protected. To learn how to stop sharing or protecting a workbook, see the links in the See Also section. 3. In the Data Validation dialog box, click the Settings tab. 4. In the Allow box, select Text Length. 5. In the Data box, select the type of restriction that you want. For example, to allow up to a certain number of characters, select less than or equal to. 6. Enter the minimum, maximum, or specific length for the text. You can also enter a formula that returns a number value.

    For example, to set the specific length for a full name field (C1) to be the current length of a first name field (A1) and a last name field (B1) plus 10, select
    

    less than or equal to in the Data box and enter =SUM(LEN(A1),LEN(B1),10) in the Maximum box. 7. To specify how you want to handle blank (null) values, select or clear the Ignore blank check box.

    **Note**   If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range, setting the
    

    Ignore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked.

    How to display an input message

    1. Click the Input Message tab. 2. Make sure the Show input message when cell is selected check box is selected. 3. Fill in the title and text for the message.
    2. Specify how you want Microsoft Office Excel to respond when invalid data is entered.

    How to specify a response to invalid data

    1. Click the Error Alert tab, and make sure that the Show error alert after invalid data is entered check box is selected. 2. Select one of the following options for the Stylebox: - To display an information message that does not prevent entry of invalid data, select Information. - To display a warning message that does not prevent entry of invalid data, select Warning. - To prevent entry of invalid data, select Stop. 3. Fill in the title and text for the message (up to 225 characters).
       **Note**  If you don't enter a title or text, the title defaults to "Microsoft Excel" and the message to: "The value you entered is not valid. A user has restricted values that can be entered into this cell."
      
    2. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip  If you change the validation settings for a cell, you can automatically apply your changes
    4 people found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-09-30T19:00:36+00:00

    I'm learning way more about Excel than I ever knew I wanted!

    This worked perfectly, even allowed me to customize the error message for my specific audience.

    Thanks!

    0 comments No comments
  2. Anonymous
    2016-09-30T13:11:18+00:00

    I'm sure one of the really clever contributors (as opposed to me that is) can use some means of Worksheet_SelectionChange() to identify rogue entries and by using a message box allow the user to ignore, retry, etc.

    I've tried the 2 minute fix but I have a problem with the test being performed on the cell it's going to not the cell it's coming from.

    I'll keep trying

    0 comments No comments
  3. Anonymous
    2016-09-29T20:04:50+00:00

    This would be bad in the situation that I have. This cell reflects the development requirements, so to simply drop characters passed the 255 mark means that certain requirements wouldn't be mapped to QA tests.

    The data is hand entered by the QA testers, so the ideal solution would involve an alert to the person entering the data, such that they could then re-format the data so as to not exceed the data limit.

    Thanks for the answer!

    0 comments No comments
  4. Anonymous
    2016-09-29T19:01:08+00:00

    How is the data originally entered to the cells in Excel?

    Would you want to use event code to limit the cells to 255 characters upon entry so there would be no need for Data Validation?

    Any chars past 255 would simply be dropped upon entry.

    Gord

    0 comments No comments