• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help Simplifying Formula

Tiago MF

Member
Hi guys

I created a formula to check if a NIF (Fiscal Identification Number) is valid.

The NIF is a 9 digits number, with the last one being a control digit which is calculated using the other eight digits the following way:
  1. Multiply the 1st digit by 9, the 2nd by 8, the 3rd by 7, …, and the 8th by 2;
  2. Sum up these results and then calculate the mod 11 of this sum;
  3. If the remainder is 0 or 1, the control digit will be 0;
  4. If it’s another number (x), the control digit is the result of 11 – x
Thus one can make a formula to calculate a control digit based on the first 8 digits of a NIF and then compare it with the 9th digit and check if they are the same. If so, the NIF is valid.

You can see the formula I created on the Upload File, cell D2, which was then copied to the rows below.

Problem is that the formula looks nastily long to me…I was wondering if there’s a clever way to simplify it :)

I’ve deconstructed my formula on Column G which makes it easier to follow the logic I applied.

Thanks in advance!

EDIT: File uploaded now
 

Attachments

  • NIF_Validation.xlsx
    10.8 KB · Views: 11
Last edited:
Thanks Misra!

Actually one of my main flaws is that I rarely use named formulas, but I reckon they are very helpful in making a formula more readable. I shall use it more in the future.

Thanks again for the suggestion!

Cheers
 
:eek: Amazing Haseeb! That's exactly the kind of simplifying I was looking for! I especially like how you have used the Text function, never seen anything like that before, very interesting.

Thanks a lot!
 
Back
Top