+ Reply to Thread
Results 1 to 14 of 14

NRIC Checksum

  1. #1
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Question NRIC Checksum

    Hello i am writing an formula to check my checkum of NRIC

    However i encounter issue where i keep returning false

    Please Login or Register  to view this content.
    I have try use https://nric.biz/ to give me an nric and i try to put in my excel sheet however it keep returning false for M
    can someone help me figure why ?

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: NRIC Checksum

    you would need to provide some examples (B3 values) which generate FALSE but which you feel should be TRUE, without that there's little any can add, I suspect.

  3. #3
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Exclamation Re: NRIC Checksum

    Hi I have attached my excel file that I would use

    i will first go to https://nric.biz/

    Then change to checksum

    Then key in any number then let it generate the NRIC then copy the NRIC which the 9 letter to my excel to check the formula is true or false
    Attached Files Attached Files
    Last edited by excelvbanew; 05-04-2023 at 05:56 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: NRIC Checksum

    You were asked for some examples, not just one!

    Why should the example you have given not return FALSE? Explain the criteria for a text string to meet the check.

    On the site to which you linked, that text string returns an error message:

    D is incorrect. (Hint: it is K!)
    Last edited by AliGW; 05-04-2023 at 05:57 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Re: NRIC Checksum

    Hi as i am using the website to check my formula whether is true or false

    Cos the website will generate the correct checksum if u paste it in it will display true

    as this is an algorithm to be use with the code

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: NRIC Checksum

    How are we supposed to know the algorithm that the website is using? Are you saying that you don't know what it is?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: NRIC Checksum

    Your formula is not returning FALSE for M - M passes the criteria set. It's the final D that is being rejected.
    Attached Images Attached Images

  8. #8
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Re: NRIC Checksum

    I see it mean is the M is wrong ?

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: NRIC Checksum

    No. Look here:

    (EDIT: for 9 numbers read 9 characters in the string).
    Attached Images Attached Images
    Last edited by AliGW; 05-04-2023 at 06:41 AM.

  10. #10
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Re: NRIC Checksum

    Yes correct start with M and 9 number however only when I added M it return me with false which I not sure why from S, T, G, F it return true
    The code orginally come with working condition for S, T, G, Fhowever after google On M algorithm I added Iin the vlookup value I couldn't get no matter what

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

    Re: NRIC Checksum

    Please try

    =LET(id,B3,b,LEFT(id),s,SEQUENCE(7),m,MOD(SUM(MID(id,s+1,1)*(MOD(1-s,6)+2))+SWITCH(b,"T",4,"G",4,),11)+1,
    MID(CHOOSE(FIND(b,"0STFGM")/2,"JZIHGFEDCBA","XWUTRQPNMLK","TRQPNJLKXWU"),m,1)=RIGHT(B3))
    Attached Files Attached Files

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: NRIC Checksum

    It's because, based on your formula, the M needs to be matched with R at the end, not D, so it isn't the M that it's telling you is wrong.

    Explain in WORDS, step-by-step, what you need this part of the formula to do:

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Re: NRIC Checksum

    This formula checks whether a Singaporean National Registration Identity Card (NRIC) number is valid by verifying its checksum digit.

    The formula takes the NRIC number as input in cell B3. It first checks that the NRIC number has a length of 9 using the LEN() function.

    If the NRIC number is 9 characters long, the formula then calculates the checksum using the following steps:

    Extracts the first letter of the NRIC number using the LEFT() function, and converts it to uppercase using the UPPER() function.
    Looks up the corresponding conversion table for the first letter of the NRIC number in the array

    {"S","J","Z","I","H","G","F","E","D","C","B","A";"T","J","Z","I","H","G","F","E","D","C","B","A";"F","X","W","U","T","R","Q","P","N","M","L","K";"G","X","W","U","T","R","Q","P","N","M","L","K";"M","Y","X","W","U","T","R","Q","P","N","M","L"} using the VLOOKUP() function.
    Looks up the corresponding conversion value for the first letter of the NRIC number in the array {"S",0;"T",4;"F",0;"G",4;"M",9;"A",1;"B",2;"C",3;"D",4;"E",5;"H",6;"I",7;"J",8;"K",9} using the VLOOKUP() function.

    Multiplies each digit of the NRIC number except the first and last digits with a corresponding weight from the array {2,7,6,5,4,3,2}.
    Sums up the products obtained in step 4.

    Adds the result obtained in step 5 to the conversion value obtained in step 3, and takes the modulo 11.
    Adds 2 to the result obtained in step 6, and takes the modulo 10.

    Looks up the final conversion value in the array {"J","Z","I","H","G","F","E","D","C","B","A"} using the VLOOKUP() function.

    The formula then checks whether the final conversion value obtained in step 8 is equal to the last digit of the NRIC number using the RIGHT() function. If they are equal, the formula returns TRUE, indicating that the NRIC number is valid. Otherwise, the formula returns FALSE, indicating that the NRIC number is invalid.

    This is the original code that work from for the 4 first Starting NRIC / FIN : S, F, T, G

    Please Login or Register  to view this content.
    Last edited by excelvbanew; 05-04-2023 at 08:06 AM.

  14. #14
    Forum Contributor
    Join Date
    04-08-2023
    Location
    Singapore
    MS-Off Ver
    365, 2021
    Posts
    113

    Re: NRIC Checksum

    Nice so far this work the best it work in every scenario where it return true or false from the website i use and paste inside to the b3 Thanks hope one day i can find a better version for it, i have marked this as solved as it 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: 11
    Last Post: 09-29-2021, 08:23 AM
  2. [SOLVED] NRIC Number Correction
    By ashburnadam in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2015, 08:59 AM
  3. [SOLVED] One Digit Checksum
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-27-2014, 09:45 PM
  4. Generate MD5 Checksum
    By vibs_us in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2008, 02:25 PM
  5. Table Checksum
    By astrikor in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-16-2008, 10:11 AM
  6. [SOLVED] Calculate Checksum
    By Safi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-23-2006, 09:40 AM
  7. [SOLVED] Calculate Checksum
    By Safi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2006, 03:40 AM

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