Sum of numbers of same cell and the result will be 0 to 9 or 11, 22, 33 or 44

Redfish

New Member
Joined
Jan 23, 2018
Messages
5
Hi,
I would like to know if you could help me create one formula to excel.
I would like to make a sum of each number of same cell.
The sum has to have the result of 0 to 9 or 11 or 22 or 33 or 44.
For example: If the cell has the number 911. The sum will be 9+1+1=11
For example if the number is 9996=9+9+9+6=33
For example if the numer is 23564=2+3+5+6+4=20=2+=2
In this moment I use this formula:
=If(REST(A1;9)=0;“9”;REST(A1;9)) (but the result will be from 0 to 9)
I need to add the exception if the result is 11 or 22 or 33 or 44
Can anyone help me?
I have the formula I can cover also the result of 11 but I need also to 22 or 33 or 44
=IF(A1=11;11;IF(REST(A1;9)=0;“9”;REST(A1;9)))
I have the same question in this link
https://www.excelguru.ca/forums/showthread.php?8749-Sum-of-numbers-of-same-cell-and-the-result-will-be-0-to-9-or-11-22-33-or-44
and in
https://www.excelforum.com/excel-fo...esult-will-be-0-to-9-or-11-22-33-or-44-a.html
Thanks.
Best regards
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi, welcome to the forum!

The sum has to have the result of 0 to 9 or 11 or 22 or 33 or 44.

So the sum has to 0-9 or a multiple of 11? What happens if the result of the sum is not one of those cases?


For example if the numer is 23564=2+3+5+6+4=20=2+=2

I don't follow this? Can you elaborate?
 
Last edited:
Upvote 0
Thank you.
The cell for exemple have the number 12563 so the other cell will sum 1+2+5+6+3 until get only one digit but if the result of two digits is 11, or 22 or 33 or 44 the result will be the number 11, or 22 or 33 or 44.
In this case 1+2+5+6+3=17 => 1+7=8
In this example if I have this formula it works well
=If(REST(A1;9)=0;“9”;REST(A1;9)) (but the result will be from 0 to 9)
But I do not know how to make the exception of 11, 22, 33, 44.
 
Upvote 0
Not sure you can do it with a formula due to the recursive nature. I wrote a small UDF that would do it I think:

Code:
Public Function SumNumbers(cellValue As Variant)

Dim i As Long

SumNumbers = 0

For i = 1 To Len(cellValue)
    SumNumbers = SumNumbers + Mid(cellValue, i, 1)
Next i

Select Case SumNumbers
    Case 0 To 9, 11, 22, 33, 44
    Case Else
        SumNumbers = SumNumbers(SumNumbers)
End Select

End Function


Book1
AB
191111
2999633
3235642
427999844
Sheet1
Cell Formulas
RangeFormula
B1=SumNumbers(A1)


WBD
 
Upvote 0
Hi,
Thak you for the help.
My excel file is protected so I canot add one UDF.
I need a formula.
Best regards
 
Upvote 0
My excel file is protected so I canot add one UDF.
I need a formula.

Hi, in that case I think you'll need to use some helper columns.


Excel 2013/2016
ABCDE
1NumberResultHelper 1Helper 2Helper 3
29111111  
399963333
4235642202
5235642202
6235642202
72799984444
8222221101
999999369
10125638178
Sheet1
Cell Formulas
RangeFormula
B2=LOOKUP(9.99E+307,C2:E2)
C2=SUM(0+("0"&MID($A2,{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},1)))
D2=IF(OR(C2="",C2<10,C2={11,22,33,44}),"",SUM(0+("0"&MID(C2,{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},1))))
E2=IF(OR(D2="",D2<10,D2={11,22,33,44}),"",SUM(0+("0"&MID(D2,{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},1))))
 
Upvote 0
If you just want to add up the digits of a number in a cell then this works

=SUMPRODUCT(--MID(B1,ROW(INDIRECT("1:" & LEN(B1))),1))
 
Upvote 0
with 1 helper at column C using formula
Code:
=SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))

At column D use this formula
Code:
=IF(AND(LEN(SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))=2,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>11,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>9,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>22,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>33,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>44),SUMPRODUCT(1*MID(C1,ROW(INDIRECT("1:"&LEN(C1))),1)),SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))
 
Upvote 0
with 1 helper at column C using formula
Code:
=SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))

At column D use this formula
Code:
=IF(AND(LEN(SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))=2,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>11,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>9,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>22,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>33,SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<>44),SUMPRODUCT(1*MID(C1,ROW(INDIRECT("1:"&LEN(C1))),1)),SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))

Hi,
I tryed the second formula and I canot value the formula.
Could you confirm if it is ok.
Thanks.
Best regards
 
Upvote 0
If you're happy to use a helper column and we assume that we only need two iterations at most then you could do this:


Book1
ABC
19111111
299963333
323564220
42799984444
522222110
69999936
712563817
Sheet1
Cell Formulas
RangeFormula
B1=IF(OR(C1<10,C1=11,C1=22,C1=33,C1=44),C1,SUMPRODUCT(1*MID(C1,ROW(INDIRECT("1:"&LEN(C1))),1)))
C1=SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))


WBD
 
Upvote 0

Forum statistics

Threads
1,214,552
Messages
6,120,172
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top