Question : MOD 10 calculation

The algorithm for calculating a Mod 10 check digit is as follows:

Instructions      Example Using the number: 12345
1. Assign positions to the digits, from right to left      1st = 5
2nd = 4
3rd = 3
4th = 2
5th = 1
2. Take the odd digit positions counting from the right (1st, 3rd, 5th, etc.)      531

3. Multiply by 2      1062
4. Take the even digit positions starting from the right (2nd, 4th, etc.)      42

5. Append (4) to the front of the results of (3)      421062
6. Add the digits of (5) together      
4+2+1+0+6+2 = 15
7. Find the next highest multiple of 10      20
8. Subtract (6) from (7)      20 - 15 = 5.
Thus, 5 is the Mod 10 check digit for 12345
      12345-5


I want to put the calculation in the next cell, so I can see the input in one field and the ooutput in another field?

Answer : MOD 10 calculation

Hi

Does this work for you?  Assumes your value is in A1 without the check digit and will return the check digit in the cell where you enter the formula.  It needs to be entered with Ctrl+Shift+Enter:

=MOD(1000-SUM(IF(MOD(ROW(INDIRECT("1:"&LEN(A1&0))),2)=1,--MID(A1&0,1+LEN(A1&0)-ROW(INDIRECT("1:"&LEN(A1&0))),1),MOD(2*MID(A1&0,1+LEN(A1&0)-ROW(INDIRECT("1:"&LEN(A1&0))),1),10)+INT(2*MID(A1&0,1+LEN(A1&0)-ROW(INDIRECT("1:"&LEN(A1&0))),1)/10))),10)

Richard
Random Solutions  
 
programming4us programming4us