乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > excel身份证号码格式-excel自定义函数-身份证号校验

excel身份证号码格式-excel自定义函数-身份证号校验

作者:乔山办公网日期:

返回目录:excel表格制作

身份证号校验函数:


语法:


=shenfenzheng(身份证号)


在模块中录入下列代码:


Function shenfenzheng(身份证号 As String)


Dim arr1(), arr2(), t, leftString, s


arr1 = Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2) '系数


arr2 = Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2") '对应的结果


s = 0


s = 0


If Len(身份证号) = 18 Then


For i = 1 To 17


t = Mid(身份证号, i, 1) '取出每位数


s = s + t * arr1(i - 1) '求和


Next i


s = s Mod 11 '取余数


If arr2(s) = Mid(身份证号, 18, 1) Then '判断是否与最后一位相等


shenfenzheng = "√"


Else


shenfenzheng = "×"


End If


Else


shenfenzheng = "位数不足18位"


End If


End Function


相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网