跳到主要內容

如何計算單元格中的字符,字母和數字的數量?

當您在Excel中的單元格中鍵入數據列表時,如下面的屏幕截圖所示,您要計算所有字符的總數,或者僅計算字母的數量,或者僅計算單元格中的數字。 現在,我將討論Excel中基於此的方法。


如果要計算每個單元格中所有字符的總數,包括數字,字母和其他標記,請執行以下操作:

1.輸入此公式 = LEN(A1) (單元格A1表示要對總字符計數的單元格)為空白單元格,例如單元格B1,然後單擊 Enter 按鈕,並且已經計算了單元格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表示要計算除數字以外的字母數量的單元格,您可以根據需要進行更改),然後按 Enter 並拖動填充手柄以填充要使用此公式的範圍。 看截圖:


選擇一個空白單元格,例如,單元格B1,鍵入此公式 = SUM(LEN(A1)-LEN(SUBSTITUTE(A1,{1,2,3,4,5,6,7,8,9,0},)))) (單元格A1表示您只想計算數量的單元格,可以根據需要進行更改),然後按 Enter 並拖動填充手柄以填充要使用此公式的範圍。 看截圖:


使用此功能,您不僅可以知道單元格字符串中有多少個字母或數字,而且還可以知道字母和數字的順序。

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表示您要計數的單元格,您可以根據需要將其更改)為空白單元格,然後按 Enter 並拖動填充手柄以填充要使用此公式的範圍。 看截圖:

小提示:

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

(2)此功能不適用於包含特殊標記的單元格,例如!,@,#,$,%,^,&等。


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

在這種情況下,我介紹 Excel的Kutools計數字符 功能為你。

Excel的Kutools, 與以上 300 方便的功能,使您的工作更加輕鬆。 

安裝後 Kutools for Excel,請執行以下操作:(立即免費下載Kutools for Excel!)

1.在單元格中鍵入要計數的字符,請參見屏幕截圖:
文檔計數字符 1

2.然後選擇一個空白單元格放入結果,然後選擇一個空白單元格放入計數結果,然後單擊 庫工具 > Kutools函數 > 統計與數學 > 計數字符。 看截圖:
文檔庫工具 1

3.然後在彈出 功能參數 對話框中,選擇字符串進入 inside_text 框,然後選擇字符單元格到 查找文本 框。 然後,您可以看到計數結果出現在對話框中。
文檔計數字符 3

4。 點擊 OK,現在結果將放入您選擇的單元格中。

文檔計數字符 4

在Kutools函數中,您可以按背景或字體顏色計數數據,可以按相同的背景或字體顏色對值求和,還可以將時間轉換為十進制小時/分鐘/秒等。



計算單詞在Excel單元格中出現的次數

通常,如果一個單詞在一個需要計數的單元格中出現幾次,則可以將它們一一計數。 但是,如果單詞出現數百次,則手動計數很麻煩。 的 計算單詞出現的次數 功能 Excel的Kutools'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選項卡為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