In the application of identifying the gender based on the ID number, most people are accustomed to using the nested if function to determine whether the ID number is 18 digits or 15 digits, and then extract the 17th or 15th digit, which is odd, when judged as "male" or even when judged as "female".
Such as:
=if (Len (A2) =18,if (mod (a2,17,1), 2, "male", "female"), IF (Len (A2) =15,if (mod (Right (a2,1), 2), "Male", "female"))
Although this can get the correct results, but due to two of the 18-digit and 15-digit ID card to judge and operation, resulting in the formula is too long, less efficient. In fact, we can avoid repeated judgments by adding simple computations to the IF function, see the following formula:
=if (MOD (A2, (LEN (A2) =18) *2+15,1), 2, "male", "female")
In this formula, if the A2 cell is 18 digits, the value of LEN (A2) =18 in the formula is 1, multiplied by 2, with a value of 2, followed by 15, equals 17, and if A2 is 15, then the value of LEN (A2) =18 is 0, multiplied by 2 plus 15, the value is 15, In this way, the mid function is used to intelligently take the 17th or 15-digit number 15th in the 18-digit number, and then as a mod parameter, correctly determine the gender of the ID holder. The same method can also be used to intelligently calculate the 18-bit and 15-bit ID card date of birth and other information, the specific way to spend your brains, extrapolate.