跳到主要内容

如何限制Excel单元格中的字符长度?

Excel 中的单元格最多可容纳 32,767 个字符,仅显示 1,024 个字符,而全部 32,767 个字符在公式栏中可见。 但是,有时您可能需要将用户输入限制为单元格中的一定数量的字符,例如将其限制为 10 个字符。 本教程将向您展示如何有效限制 Excel 单元格中的字符数。


限制单元格中的字符数

本节介绍限制可输入特定单元格或单元格范围的字符数的步骤。

  1. 选择要强制执行字符长度限制的单元格范围。
  2. 点击 数据验证 ,在 数据工具 下的组 时间 标签。
  3. 数据验证 对话框中,请设置验证规则如下:
    1. 来自 允许: 下拉菜单,选择 文字长度.
    2. 来自 日期: 下拉列表中,根据您的要求选择标准:
      1. 选择 等于 精确字符数的选项,例如 10 个字符。
      2. 选择 小于或等于 最大字符数限制,例如最多 10 个字符。
      3. 选择 比...更棒 超过特定计数,例如超过 10 个字符。
    3. 最大/最低限度/长度: 框中,根据您的需要输入所需的字符数限制。
  4. 点击 OK.

现在,用户将被限制在所选单元格中的设定字符限制内输入文本。

轻松防止在Excel中的单元格/选择中键入特殊字符,数字或字母

使用 Kutools for Excel 的 防止打字 功能,您可以轻松限制 Excel 单元格或选择中的字符类型。
A。 阻止输入特殊字符,例如 *, !等等。
B。 限制输入特定字符,例如数字或某些字母;
C。 仅允许根据需要输入指定字符,例如数字或字母。

设置输入消息以通知字符限制

在这里,我们将解释如何设置输入消息,在用户开始输入之前告知用户字符限制,如下图所示:

  1. 选择要添加输入消息的单元格。
  2. 点击 数据验证 ,在 数据工具 下的组 时间 标签。
  3. 数据验证 对话框中,选择 输入信息。 标签,然后执行以下操作:
    1. 访问 选择单元格时显示输入消息 选项。
    2. 输入消息标题和消息内容。
  4. 点击 OK.

现在,当您单击配置了输入消息的单元格时,将出现一个工具提示,显示您之前输入的消息标题和内容。


激活违反字符限制的错误警报

本部分将指导您在 Excel 中配置错误警报,旨在在输入的数据不符合指定的字符限制时立即通知用户。 看截图:

  1. 选择要针对无效数据输入实例激活错误警报的单元格。
  2. 点击 数据验证 ,在 数据工具 下的组 时间 标签。
  3. 数据验证 对话框中,选择 错误警报 标签,然后执行以下操作:
    1. 访问 输入无效数据后显示错误警报 选项。
    2. 点击 警告 选项从 类型: 下拉框。
    3. 输入警报标题和错误消息。
  4. 点击 OK.

从现在开始,如果在单元格中输入的文本无效,例如超过10个字符,则会出现警告对话框,显示预设的警报标题和消息。


演示:通过输入消息和警报警告限制单元格中的字符长度


Kutools for Excel:超过 300 个方便的工具触手可及! 立即开始 30 天免费试用,没有任何功能限制。 立即下载!

一键防止在单个列/列表中输入重复数据

Kutools for Excel 的创新 防止重复 实用程序为 Excel 用户提供了轻松防止列表或列中出现重复条目​​的便利。 只需单击一下,这个强大的工具即可确保电子表格中数据的完整性和准确性。

相关文章:

如何限制Excel中的单元格值条目?

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (54)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank you!
This comment was minimized by the moderator on the site
why date and number is allowed at text length?
This comment was minimized by the moderator on the site
Hi there, numbers are also characters. So if you set the max length less than 10 characters, as long as you don't input 10 or more number characters, you will be good.

Amanda
This comment was minimized by the moderator on the site
This is almost the exact solution I need but still need a bit more help. What I'm trying to achieve is to set a cell to have a max of 40 characters but not stop the user from entering all the data he needs, instead i would like anything over the 40 character limit to be populated in a second designated cell. Is this even a possibility? Thank you everyone in advance for any assistance provided.
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
I saw Tomas question about putting an exact limit of 10 spaces and your formula =A1&REPT(" ",10-LEN(A1)) however I need to take it a step further. I want to take three separate fields that I have set their spaces to exactly 10 and concatenate them with their "spaces" intact. Also, if I don't limit what they enter and they enter MORE than 10 characters in one of the cells I want to take ONLY the first 10. So as an example, I want to give them three cells they can enter information in. I don't want to limit what they input BUT, I want to concatenate these three fields and pick up 10 characters from each one. So if the first cell has 4 characters, in my concatenate formula I want it to pick up the 4 characters PLUS 6 spaces. If the second field has 20 characters, I want to only pick up the first 10 characters and the same thing for the third cell. We are trying to get to a uniform 30 characters of description but some names are longer or shorter than others. We want this to break evenly with 10 characters per cell. Hopefully this is making sense.
This comment was minimized by the moderator on the site
Hi, do you know how to put exact length limit 10 and when put abc i want from excel to put 8 space?
I want to set a cell to 10 character, when input 2 character then will auto fill up with 8 space after. if the cell is blank, then return with 10 space. this is for setting a excel file for user input and save as txt or cvs file for import to other software.
This comment was minimized by the moderator on the site
Hi Tomas,
You can use a formula to limit the text length: =A1 & REPT(" ",10-LEN(A1))
This comment was minimized by the moderator on the site
I want to limit the quantity of a cell depending on the category of another one,

For example if I input in A1 "Ok" in B1 must be limit to 10 characters
but if A1= "NG", B1 must be limit to 12 characters.
This comment was minimized by the moderator on the site
[quote]Hi, do you know how to put exact length limit 10 and when put abc i want from excel to put 8 space?By Ivan[/quote] I want to set a cell to 10 character, when input 2 character then will auto fill up with 8 space after. if the cell is blank, then return with 10 space. this is for setting a excel file for user input and save as txt or cvs file for import to other software
This comment was minimized by the moderator on the site
Hi, I have a attendance sheet. from 1 to 31. I put "P" on each cell if person is present. Now I want that how many times "P" is continuing present in cell. As as example - I have put "P" from 1 to 6 , then from 8th to 9th put P, and 10th is gap. then from 11th its continue to 18th. ... now i want how many times P is continue 6 time . PPPPPP PP PPPPPPPP Manually the answer is : 2(1to6 = 1,11to18=1) If you have any formula to count this it will be a great help.
This comment was minimized by the moderator on the site
=COUNTIF(B2:B17,">""") this formula will ignore empty cells but will count cells with data in i.e. P
This comment was minimized by the moderator on the site
Hi. I want out put txt file and no spaces between cell values. Like 3 cells with First Name, Middle and last. Entered Shawn G Goldman as SHAWNGGOLDMAN
This comment was minimized by the moderator on the site
Hi I want few things in a cell. I only want numbers in cell. I want to limit to 10 characters. I want to remove decimal like 15.00 to 1500. I want to indent to right. Also to add 0's to left to make it 10 characters .like 15.00 to 0000001500
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations