Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to count the number of characters, letters and numbers in cell?

When you type a list of data in a cell in Excel as shown as below screenshot, you want to count the total number of all characters, or only the number of the letters, or only the numbers in the cell. Now, I talk about the methods on this count in Excel.


Count times a word appears in an excel cell

If a word appears several times in a cell which needed to be count, usually, you may count them one by one. But if the word appears hundreds of times, the manually counting is troublesome. The Count times a word appears function in Kutools for Excel's Formula Helper group can quickly calculate the count of times a word appear in a cell. Free trial with full features in 60 days!
doc count times a word
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

If you want to count the total number of all characters, including numbers, letters and other marks in each cell, do it as follow:

1. Type this formula =LEN(A1) (the Cell A1 indicates the cell you want to count the total characters) into a blank cell, for example, the Cell B1, and click Enter button on the keyboard, and the total number of characters in Cell A1 has been counted. See screenshot:

2. Drag the fill handle to apply this formula to the range cells, and the number of characters in each cell of the list have been counted. See screenshot:


If you only want to the amount of letters excluding numbers in each cell, you can do as follow:

Select a blank cell, for example, the Cell B1, type this formula  =LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,""))
(the Cell A1 indicates the cell you want to count amount of letters except numbers, you can change it as you need), then press Enter and drag the fill handle to fill the range you want to use this formula. See screenshot:


Select a blank cell, for example, the Cell B1, type this formula =SUM(LEN(A1)-LEN(SUBSTITUTE(A1,{1,2,3,4,5,6,7,8,9,0},))) (the Cell A1 indicates the cell you want to count only amount of numbers, you can change it as you need), then press Enter and drag the fill handle to fill the range you want to use this formula. See screenshot:


With this function, you not only can know how many letters or numbers in the string of the cell, but also know the orders of the letters and numbers.

1. Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window.

2. Click Insert > Module, and copy the VBA into the module.

VBA: Count amount of letters and numbers with function

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. Save the code and close the window, and type this formula =AlphaNumeric(A1) ( the Cell A1 indicates the cell you want to count, you can change it as you need) into a blank cell, then press Enter and drag the fill handle to fill the range you want to use this formula. See screenshot:

Tip:

(1) The "L" indicates letter and "N" indicates number.

(2) This function does not work with cells containing special marks, such as !, @, #, $, %, ^, &, etc.


If you want to count the number of a specific character in a string, for example, in the string “I want to count the number of a specific in a string”, I want to count the number of character “n”, how can you do?

In this case, I introduce Kutools for Excel’s COUNTCHAR function for you.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

1. Type the character you want to count in a cell, see screenshot:
doc countchar 1

2. Then select a blank cell to put the result and select a blank cell which will put the counting result, and click Kutools > Kutools Functions > Statistical & Math > COUNTCHAR. See screenshot:
doc kutools 1

3. Then in the popping Function Arguments dialog, select the string into Within_text box, and select the character cell into the Find_text box. Then you can see the counting result appears in the dialog.
doc countchar 3

4. Click OK, now the result is put in the cell you select.

doc countchar 4

In Kutools Functions, you can count data by background or font color, you can sum values by same background or font color, you can convert time to decimal hours/minute/seconds and so on.



Sum numbers in an excel cell

Sometimes, there is a series of numbers in a cell needed to be summed together, for example, 923149, sum is 28. In Excel, there is no built-in function except sum numbers one by one manually. However, the Sun numbers in a cell function in Kutools for Excel's Formula Helper group can quickly calculate total number of numbers in a cell. Free trial for 60-day with full features!
doc sum numbers in a cell
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

Relative Articles:

  • Change text strings to sentence case
  • Change text strings to uppercases

  • Recommended Productivity Tools

    Ribbon of Excel (with Kutools for Excel installed)

    300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

    Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

    •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
    •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
    •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
    •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
    •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
    •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
    •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
    •  Change the way you work now, and give you a better life immediately!

    Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

    • Increases your productivity by 50% when viewing and editing multiple documents.
    • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
    • Open and create documents in new tabs of same window, rather than in new windows.
    • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
    Say something here...
    symbols left.
    You are guest ( Sign Up? )
    or post as a guest, but your post won't be published automatically.
    Loading comment... The comment will be refreshed after 00:00.
    • To post as a guest, your comment is unpublished.
      David · 2 months ago
      Hi excel experts, is there some easy coding to count characters how often characters come in line. for example if I have the following line:
      ABBABBCCCBCCBCCCBB and I want to know how many times there are three (3) C in a row? in this case the correct answer is 2 times. But I would like to write a code to counts for me. It is possible?
      • To post as a guest, your comment is unpublished.
        Sunny · 2 months ago
        Sorry, I do not have any tricks on solving this job.
    • To post as a guest, your comment is unpublished.
      Vikas · 7 months ago
      hi need a help eg: =+1+2+3+4+5+6 now i want how many numbers in a common cell . Is that possible .Still i am not able to find any solution m keep searching from last 4 months . May Be you provide a better solution
      • To post as a guest, your comment is unpublished.
        Sunny · 6 months ago
        You can add' in the front of =1+2+3+4+5+6 to convert the formula to text, then apply Kutools for Excel's Remove by character to remove all characters except numbers, and use =LEN() to count the number.
    • To post as a guest, your comment is unpublished.
      patrick · 11 months ago
      Thankyou very much :) you helped me
    • To post as a guest, your comment is unpublished.
      Alex · 1 years ago
      Hi, i need to count numbers situated between characters, like in the example bellow, help me please.

      example: 1,2,3,4,5,67,89,8657,6789,23456,10

      i have 11 numbers situated between comma, is there a formula for this type of counting?

      Thank you.
    • To post as a guest, your comment is unpublished.
      Ivan Kesaulya · 1 years ago
      Hi excel experts, can you help me?
      I need to count previous numbers before special characters appeared.


      123456789|


      Could you help me?


      Thank you.
      • To post as a guest, your comment is unpublished.
        Sunny · 1 years ago
        Your question is a little complex, I cannot find a formula to solve it. But you can handle it like these:

        1. Extract all characters before the special character =LEFT(A1,FIND(",",A1)-1), the comma is the special character

        2. Then use the formula =LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
        (A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,"")) to count the numbers only.