权当身份证号码在A2单元格
有两个验证公式
18位单一校验:
=IF(AND(LEN(A2)=18,CHOOSE(MOD(SUMPRODUCT(MID(A2,ROW($1:$17),1)*2^(18-ROW($1:$17))),11)+1,1,0,"X",9,8,7,6,5,4,3,2)&""=RIGHT(A2)),"有效","无效!!")
通用(18位、15位均可)校验:
=IF(LEN(A2)=18,IF(CHOOSE(MOD(SUMPRODUCT(MID(A2,ROW($1:$17),1)*2^(18-ROW($1:$17))),11)+1,1,0,"X",9,8,7,6,5,4,3,2)&""=RIGHT(A2),"正确","错误"),IF(LEN(A2)=15,IF(CHOOSE(MOD(SUMPRODUCT(MID(A2,ROW($1:$14),1)*2^(15-ROW($1:$14))),11)+1,1,0,"X",9,8,7,6,5,4,3,2)&""=RIGHT(A2),"正确","错误"),"错误"))