跳到主要内容

如何计算单元格中的字符,字母和数字的数量?

当您在Excel中的单元格中键入数据列表时,如下面的屏幕截图所示,您要计算所有字符的总数,或者仅计算字母的数量,或者仅计算单元格中的数字。 现在,我将讨论Excel中基于此的方法。


如果要计算每个单元格中所有字符的总数,包括数字,字母和其他标记,请执行以下操作:

1.输入此公式 = LEN(A1) (单元格A1表示要对总字符计数的单元格)为空白单元格,例如单元格B1,然后单击 输入 按钮,并且已经计算了单元格A1中的字符总数。 看截图:

2.拖动填充手柄以将该公式应用于范围单元格,并且列表中每个单元格中的字符数都已计算在内。 看截图:


如果只希望每个单元格中的字母数不包括数字,则可以执行以下操作:

选择一个空白单元格,例如,单元格B1,键入此公式

=LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,""))

(单元格A1表示要计算除数字以外的字母数量的单元格,您可以根据需要进行更改),然后按 输入 并拖动填充手柄以填充要使用此公式的范围。 看截图:


选择一个空白单元格,例如,单元格B1,键入此公式 = SUM(LEN(A1)-LEN(SUBSTITUTE(A1,{1,2,3,4,5,6,7,8,9,0},)))) (单元格A1表示您只想计算数量的单元格,可以根据需要进行更改),然后按 输入 并拖动填充手柄以填充要使用此公式的范围。 看截图:


使用此功能,您不仅可以知道单元格字符串中有多少个字母或数字,而且还可以知道字母和数字的顺序。

1.按住 ALT 按钮并按下 F11 在键盘上打开一个 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将VBA复制到模块中。

VBA:使用功能计算字母和数字的数量

Function AlphaNumeric(pInput As String) As String
'Updateby20140303
Dim xRegex As Object
Dim xMc As Object
Dim xM As Object
Dim xOut As String
Set xRegex = CreateObject("vbscript.regexp")
xRegex.Global = True
xRegex.ignorecase = True
xRegex.Pattern = "[^\w]"
AlphaNumeric = ""
If Not xRegex.test(pInput) Then
    xRegex.Pattern = "(\d+|[a-z]+)"
    Set xMc = xRegex.Execute(pInput)
    For Each xM In xMc
        xOut = xOut & (xM.Length & IIf(IsNumeric(xM), "N", "L"))
    Next
    AlphaNumeric = xOut
End If
End Function

3.保存代码并关闭窗口,然后键入此公式 =字母数字(A1) (单元格A1表示要计数的单元格,您可以根据需要进行更改)为空白单元格,然后按 输入 并拖动填充手柄以填充要使用此公式的范围。 看截图:

提示:

(1)“ L”表示字母,“ N”表示数字。

(2)此功能不适用于包含特殊标记的单元格,例如!,@,#,$,%,^,&等。


如果要计算字符串中特定字符的数量,例如,在字符串“我要计算字符串中特定字符的数量”中,我想计算字符“ n”的数量,如何你做?

在这种情况下,我介绍 Kutools for Excel计数字符 功能为你。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

安装后 Kutools for Excel,请执行以下操作:(立即免费下载Kutools for Excel!)

1.在单元格中键入要计数的字符,请参见屏幕截图:
文档计数字符 1

2.然后选择一个空白单元格放入结果,然后选择一个空白单元格放入计数结果,然后单击 库工具 > Kutools函数 > 统计与数学 > 计数字符。 看截图:
文档库工具 1

3.然后在弹出 功能参数 对话框中,选择字符串进入 inside_text 框,然后选择字符单元格到 查找文本 框。 然后,您可以看到计数结果出现在对话框中。
文档计数字符 3

4。 点击 OK,现在结果将放入您选择的单元格中。

文档计数字符 4

在Kutools函数中,您可以按背景或字体颜色计数数据,可以按相同的背景或字体颜色对值求和,还可以将时间转换为十进制小时/分钟/秒等。



计算单词在Excel单元格中出现的次数

通常,如果一个单词在一个需要计数的单元格中出现几次,则可以将它们一一计数。 但是,如果单词出现数百次,则手动计数很麻烦。 的 计算单词出现的次数 功能 Kutools for Excel's 公式助手 小组可以快速计算单词在单元格中出现的次数。 30 天内免费试用全部功能!
 
Kutools for Excel:拥有300多个便捷的Excel加载项,可以在30天内免费试用。

相关文章:

最佳办公生产力工具

🤖 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 (29)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hola esta formula: = SUMA(LONG(A1) -LEN (SUSTITUTO (A1, {1;2;3;4;5;6;7;8;9;0},))). No se como usarla en windows
This comment was minimized by the moderator on the site
Excel của tôi là 2007
Đã nhiều lần làm công thức = LEN (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE (SUBSTITUTE)
(A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,"")) mà ko thành công.
Mong Admin vui lòng trợ giúp!
Xin cám ơn!
This comment was minimized by the moderator on the site
Hi, maybe there is a line break in the formula which cause the error. I have modified the formula, please try again.
This comment was minimized by the moderator on the site
Thank you! Have bulleted statements in cells, have now been able to count them as individual items, brilliant!
This comment was minimized by the moderator on the site
Hi... how to set the formulas on Accuracy limits 98.1 to 103 - means exact 3 digits allow only.
This comment was minimized by the moderator on the site
How to enter this equation in excel
(4+y)/(2x+y)^2+12 whiles x=1 y=3 by naming x and y as 1 and 3 respectively
This comment was minimized by the moderator on the site
Can solve it for me.. Iwant count of this cell :-
1+1.5+2+1.5+2.5+1+3+3.5

1=?, 1.5=?, 2=?, 2.5=?, 3=?, 3.5=?... using LEN but ans.wrong (1=4, 1.5=2, 2=2, 2.5=1, 3=2, 3.5=1)

Please help me.
This comment was minimized by the moderator on the site
1+2+3+4+5+6 I need help with this one. How can I ACTUALLY figure this out...?
This comment was minimized by the moderator on the site
It was a little Confusing but I knew this will be a good help for me because I just knew typing like coding this was such a good idea in order thx very much.
This comment was minimized by the moderator on the site
I thank you for how I understand what that meant?
This comment was minimized by the moderator on the site
Hello, How can I check for password validation that is stored as excel cell data using vba script and display message for all the wrong entries showing the location of error?
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