Excel's handling of the ID number

First, the date of birth is extracted from the ID number.

ID number of the original so much hidden secret, you know how to deal with it?

 

method:

Enter the formula in the target cell: = TEXT (MID (C3,7,8), "00-00-00").

Interpretation:

1, the role of MId function is: a text character from the specified home position return pass of the specified length. Syntax structure is: = Mid (string, starting position, length).

2, the role of Text function is: The development of the numerical value is converted to text format.

3, the formula: = TEXT (MID (C3,7,8), "00-00-00"), the first extracted from the cell C3 is started with bit 7 Mid function, character length of 8, followed by Text function set to the format of "00-00-00" (cum date) text.


Second, gender extracted from the ID number.

ID number of the original so much hidden secret, you know how to deal with it?

 

method:

Enter the formula in the target cell: = IF (MOD (MID (C3,17,1), 2), "male", "female").

Interpretation:

1, the role of Mod function is: Returns the remainder of dividing two numbers. Syntax structure is: = Mod (dividend, divisor), for example = Mod (6,2), the return value is 0; = Mod (3,2), a return value.

2. If action function is: judging condition is established, if the establishment of a return value, otherwise it returns the value of another.

3, the formula: in = IF (MOD (MID (C3,17,1), 2), "M", "F"), using the first position 17 Mid function to extract the string in cell C3, then divided by 2, returns the remainder (cum action Mod function, which returns a structure only 0 and 1, two), and finally the remainder with If function to determine if it is "1", return to "male", and if "0" to return to "female . "


Third, the extracts from the age identity card number.

ID number of the original so much hidden secret, you know how to deal with it?

 

method:

Enter the formula in the target cell: = DATEDIF (D3, TODAY (), "y").

Interpretation:

1, Datedif function is a function to hide the system, its role as the difference between the two dates is calculated in accordance with the specified type. The syntax structure: = Datedif (start date, end date, statistical methods), common "statistical methods" has: "Y", "M", "D"; namely "year", "month", "day" .

2, the role Today () function to get today's date.


Fourth, the calculation of retirement age with identity card number.

ID number of the original so much hidden secret, you know how to deal with it?

 

method:

在目标单元格中输入公式:=EDATE(D3,MOD(MID(C3,17,1),2)*120+600)。

解读:


1、Edate函数的作用为返回指定日期之前或之后X月的日期。语法结构为:=Edate(指定日期,月份)。

2、公式:=EDATE(D3,MOD(MID(C3,17,1),2)*120+600)中,首先用判断性别,如果为“男”性,则公式为:=Edate(D3,1*120+600),暨从出生日期算起之后的720个月(暨60年)的日期;如果为“女性”,则公式为:=Edate(D3,0*120+600),暨从出生日期算起之后的600个月(暨50年)的日期。


五、判断身份证号是否重复。

1、常规操作(错误办法)。

ID number of the original so much hidden secret, you know how to deal with it?

 

方法:

在目标单元格中输入公式:=IF(COUNTIF($C$3:$C$9,C3)>1,"重复","")。

解读:

1、Countif函数是单条件计数函数,其语法结构为:=Countif(条件范围,条件)。

2、利用Countif函数统计出当前值在C3:C9范围内数量,紧接着和1进行比较,并用If函数来判断,如果比较的结果成立,则返回“重复”,否则返回空值。

3、从单元格值中可以看出,两个身份证号并不重复,但是返回的结果为“重复”,Why?因为在Excel中的数字的有效位数为15位,超过15位的全部按“0”处理。而上述的两个号码中只有最后两位不同,故被Excel作为“0”处理,因此判断的结果为“重复”。


2、正确做法。

ID number of the original so much hidden secret, you know how to deal with it?

 

方法:

在目标单元格中输入公式:=IF(COUNTIF(C$3:C$9,C3&"*")>1,"重复","")。

解读:

1、此公式和“常规操作”的公式比较,只是在C3后添加了&"*",但能得到正确的结果,Why?

2、“*”在Excel中被称为通配符,起作用就是将当前的数字强制转换为文本,然后进行比较,从而得到了正确的结果。


六、防止身份证号重复。

ID number of the original so much hidden secret, you know how to deal with it?

 

方法:

1、选定目标单元格。

2, [Data] - [Verification], [allows] select the custom] [,] and [Equation enter: = COUNTIF (C $ 3: C $ 9, C3) = 1.

3, improve the message and OK.

 

Guess you like

Origin www.cnblogs.com/johnnyblog/p/11372481.html