Here my option is quite similar to the one already sent, but in any case ... especially if you are interested in learning, which is so rare today)
Assuming you have a list starting with A2, use the following array formula:
=SUM(LEN($A2)-LEN(SUBSTITUTE($A2,CHAR(ROW(INDIRECT(CODE("a")&":"&CODE("f")))),"")))
As a reminder, press CTRL + SHIFT + ENTER instead of the usual ENTER .
Some explanations:
- The letter range af is generated using the char range codes of the edges of the range, converted back to an array of characters using the
CHAR(ROW(INDIRECT(...))) structure CHAR(ROW(INDIRECT(...))) . - Then comes the "nightmare", summing up the resulting numbers of substituted vs original subtractions of the rows.
- Thus, in the case of such a double conversion, you do not need a code one)))
And two more similar samples of "nuts" - for educational purposes only.
If you need to sum all digits of digits , you can still use the above using 0 and 9 as input (numbers are characters from 48 to 57 codes starting with 0). However, an even simpler solution will follow:
=SUM(LEN($A2)-LEN(SUBSTITUTE($A2,ROW($1:$10)-1,"")))
The trick here is that we can generate numbers 0-9 using the numbers of arrays or strings 1-10 minus 1 - ROW(0) to generate an error.
Finally, if you need to calculate the sum of all the digits in a string, use this:
=SUM(IFERROR(VALUE(MID($A2,ROW(INDIRECT("1:"&LEN($A2))),1)),0))
Here we disintegrate the initial string into letters using MID for each single char, and then check it for a number with IFERROR and return 0 for anything other than a digit.
The last 2 (obviously) your favorite massive nuts)))
I use the above examples in my Excel training for QA materials (by the way, welcome to SE, colleague!), Thereby demonstrating typical functions / approaches to cracking nuts. I hope this was useful to you. However, all of the previous answers deserve at least your fair promotion, especially over-the-counter @barry prescription)
For your convenience, the sample file is shared: https://www.dropbox.com/s/qo5k479oyawkrzh/SumLettersCount.xlsx
Good luck in testing)