+ Reply to Thread
Results 1 to 8 of 8

Want to make short a formula

Hybrid View

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2021, Google Sheet
    Posts
    38

    Want to make short a formula

    Hi,

    I have created a formula to find out last digit of 18 digit numbers. Actually I got this formula by using lugn algorithm. Here is the formula. Also attached a sample file in this regards.
    Formula: copy to clipboard

    =IFERROR(A2&IF(VALUE(RIGHT(MID(A2,1,1)+IF(LEN(MID(A2,2,1)*2)=2,RIGHT(MID(A2,2,1)*2,1)+LEFT(MID(A2,2,1)*2,1),MID(A2,2,1)*2)+MID(A2,3,1)+IF(LEN(MID(A2,4,1)*2)=2,RIGHT(MID(A2,4,1)*2,1)+LEFT(MID(A2,4,1)*2,1),MID(A2,4,1)*2)+MID(A2,5,1)+IF(LEN(MID(A2,6,1)*2)=2,RIGHT(MID(A2,6,1)*2,1)+LEFT(MID(A2,6,1)*2,1),MID(A2,6,1)*2)+MID(A2,7,1)+IF(LEN(MID(A2,8,1)*2)=2,RIGHT(MID(A2,8,1)*2,1)+LEFT(MID(A2,8,1)*2,1),MID(A2,8,1)*2)+MID(A2,9,1)+IF(LEN(MID(A2,10,1)*2)=2,RIGHT(MID(A2,10,1)*2,1)+LEFT(MID(A2,10,1)*2,1),MID(A2,10,1)*2)+MID(A2,11,1)+IF(LEN(MID(A2,12,1)*2)=2,RIGHT(MID(A2,12,1)*2,1)+LEFT(MID(A2,12,1)*2,1),MID(A2,12,1)*2)+MID(A2,13,1)+IF(LEN(MID(A2,14,1)*2)=2,RIGHT(MID(A2,14,1)*2,1)+LEFT(MID(A2,14,1)*2,1),MID(A2,14,1)*2)+MID(A2,15,1)+IF(LEN(MID(A2,16,1)*2)=2,RIGHT(MID(A2,16,1)*2,1)+LEFT(MID(A2,16,1)*2,1),MID(A2,16,1)*2)+MID(A2,17,1)+IF(LEN(MID(A2,18,1)*2)=2,RIGHT(MID(A2,18,1)*2,1)+LEFT(MID(A2,18,1)*2,1),MID(A2,18,1)*2),1))=0,0,10-VALUE(RIGHT(MID(A2,1,1)+IF(LEN(MID(A2,2,1)*2)=2,RIGHT(MID(A2,2,1)*2,1)+LEFT(MID(A2,2,1)*2,1),MID(A2,2,1)*2)+MID(A2,3,1)+IF(LEN(MID(A2,4,1)*2)=2,RIGHT(MID(A2,4,1)*2,1)+LEFT(MID(A2,4,1)*2,1),MID(A2,4,1)*2)+MID(A2,5,1)+IF(LEN(MID(A2,6,1)*2)=2,RIGHT(MID(A2,6,1)*2,1)+LEFT(MID(A2,6,1)*2,1),MID(A2,6,1)*2)+MID(A2,7,1)+IF(LEN(MID(A2,8,1)*2)=2,RIGHT(MID(A2,8,1)*2,1)+LEFT(MID(A2,8,1)*2,1),MID(A2,8,1)*2)+MID(A2,9,1)+IF(LEN(MID(A2,10,1)*2)=2,RIGHT(MID(A2,10,1)*2,1)+LEFT(MID(A2,10,1)*2,1),MID(A2,10,1)*2)+MID(A2,11,1)+IF(LEN(MID(A2,12,1)*2)=2,RIGHT(MID(A2,12,1)*2,1)+LEFT(MID(A2,12,1)*2,1),MID(A2,12,1)*2)+MID(A2,13,1)+IF(LEN(MID(A2,14,1)*2)=2,RIGHT(MID(A2,14,1)*2,1)+LEFT(MID(A2,14,1)*2,1),MID(A2,14,1)*2)+MID(A2,15,1)+IF(LEN(MID(A2,16,1)*2)=2,RIGHT(MID(A2,16,1)*2,1)+LEFT(MID(A2,16,1)*2,1),MID(A2,16,1)*2)+MID(A2,17,1)+IF(LEN(MID(A2,18,1)*2)=2,RIGHT(MID(A2,18,1)*2,1)+LEFT(MID(A2,18,1)*2,1),MID(A2,18,1)*2),1))),"")


    This formula is working fine. I need this formula in short. Please help me by doing this.
    Attached Files Attached Files
    Last edited by davesexcel; 09-15-2020 at 01:29 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Want to make short a formula

    You explanation does not make sense, why would you need all that to get the last digit of an 18 digit number?

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.96 for Mac MS 365
    Posts
    8,697

    Re: Want to make short a formula

    @davesexcel, I suspect the formula is taking apart the 18 digit number and depending on what numbers occur at different positions it is adding different numbers to the end - the 20 digit number (which BTW in the attached example is only 19 digits long).
    It hurts my head to try to take it apart to see what each formula section is doing but I suspect that if Mofasol gave an explanation about what the criteria is for it to determine what number to append to the end something could be developed.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Want to make short a formula

    It will take less time if you just explain what you're trying to do, and form a new formula accordingly then analyze the billion lines you have created in your file.

  5. #5
    Registered User
    Join Date
    08-06-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2021, Google Sheet
    Posts
    38

    Re: Want to make short a formula

    As I said that, I got the 19th number by using Luhn algorithm method. for better understanding see the below link.

    https://en.wikipedia.org/wiki/Luhn_algorithm

    1st 18 digit is serial. I need 19th number and it should be unique and of course get by using Luhn algorithm method.

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,659

    Re: Want to make short a formula

    First time hearing about public digits organization. Very interesting issue. Now I can check if my social number is in right manner or not.

    Try for A2 digits:

    =A2&RIGHT(10-RIGHT(SUMPRODUCT(MID(A2,ROW($1:$9)*2-1,1)+MID(A2,ROW($1:$9)*2,1)*2-(MID(A2,ROW($1:$9)*2,1)+0>5)*9)))
    with 9 = 18 digits/2. Change it to 8 for 16-digit case.
    Last edited by bebo021999; 09-16-2020 at 03:42 AM.
    Quang PT

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Want to make short a formula

    I got this
    C2
    =A2&MOD(SUMPRODUCT((MOD(MID(A2,ROW($A$1:$A$9)*2-{1,0},1)*{1,2}-1,9)+1)*(-MID(A2,ROW($A$1:$A$9)*2-{1,0},1)*{1,2}<0))*9,10)

    and shorten one
    =A2&MOD(SUMPRODUCT(MOD(MID(A2,ROW($1:$9)*2-{1,0},1)*{1,2},9)-(--MID(A2,ROW($1:$9)*2-{1,0},1)=9))*9,10)
    Attached Files Attached Files
    Last edited by Bo_Ry; 09-16-2020 at 04:19 AM. Reason: Correction

  8. #8
    Registered User
    Join Date
    08-06-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2021, Google Sheet
    Posts
    38

    Re: Want to make short a formula

    Quote Originally Posted by Bo_Ry View Post
    I got this
    C2
    =A2&MOD(SUMPRODUCT((MOD(MID(A2,ROW($A$1:$A$9)*2-{1,0},1)*{1,2}-1,9)+1)*(-MID(A2,ROW($A$1:$A$9)*2-{1,0},1)*{1,2}<0))*9,10)

    and shorten one
    =A2&MOD(SUMPRODUCT(MOD(MID(A2,ROW($1:$9)*2-{1,0},1)*{1,2},9)-(--MID(A2,ROW($1:$9)*2-{1,0},1)=9))*9,10)
    Its working! Thank you very much for doing this great work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 01-16-2018, 06:52 PM
  2. Short issue with formula.
    By sarstep1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-25-2017, 11:09 AM
  3. How to make the short border?
    By ajing in forum Excel General
    Replies: 3
    Last Post: 01-27-2016, 02:56 PM
  4. Want to short formula instead of using of CONCATENATE
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-21-2014, 03:28 AM
  5. Userform find/search text, can i make it's short code ?
    By johnreid7477 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-03-2014, 04:28 PM
  6. Shortening of long array formula by short formula
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2013, 05:51 AM
  7. In search of a formula short cut...
    By johnnioaf in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2012, 03:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1