Padeen wrote:Subject: Adding two digits together of a two-digit number:
Is there a formula in OOC that I can use either digit separately of a two-digit number for a calculation? Or, how do I return digit x, or y, or z of an xyz number?
Adding to
Zizi64's second solution with value 235 in cell A2:
=MOD(QUOTIENT($A$2;10^0);10) is 5 (digit position 0)
=MOD(QUOTIENT($A$2;10^1);10) is 3 (digit position 1)
=MOD(QUOTIENT($A$2;10^2);10) is 2 (digit position 2)
=MOD(QUOTIENT($A$2;10^3);10) is 0 (digit position 3)
=MOD(QUOTIENT($A$2;10^4);10) is 0 (digit position 4)
Thus, you can use the same expression structure for each digit position. The exponent (0,1,2,3,4) could also be a cell reference.
More generally, since you have asked about adding digits together:
=SUM(MOD(QUOTIENT($A$2;10^{0;1});10)) is 8 (5+3) (digit positions 0 and 1)
=SUM(MOD(QUOTIENT($A$2;10^{1;2});10)) is 5 (3+2) (digit positions 1 and 2)
=SUM(MOD(QUOTIENT($A$2;10^{0;2});10)) is 7 (5+2) (digit positions 0 and 2)
=SUM(MOD(QUOTIENT($A$2;10^{0;1;2});10)) is 10 (5+3+2) (digit positions 0, 1, and 2)
Each SUM() expression must be entered as an
Array formula so type it and
and press ⇪⌘Enter (Shift+Command+Enter) on a Mac or Ctrl+Shift+Enter on other platforms; if you press Enter by mistake, use Edit → Delete Contents → Formulas, then try again.
If you need further assistance
attach a document demonstrating the situation
(remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the document itself).
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6. The locale for any menus or Calc formulas in my posts is English (USA).