謝謝G大的回覆
巳刪除此條 If Rng.Cells(Rng.Cells.Count).End(xlToLeft).Address <> Rng.Cells(1).Address Then MsgBox "資料位置有誤 ! 請檢查 ": Exit Sub可正常運作
,但輸入身分證還是無法檢驗是否輸入正確與否?
是要在加入政府驗證程序嗎???
例如
Private Sub Worksheet_Change(ByVal Target As Range) '借戶身分證檢查
Dim T, i%, S
With Target
If .Count > 1 Then Exit Sub
If Intersect([B51:P51], .Cells) Is Nothing Then Exit Sub
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
If Not .Value Like "[A-Z]#########" Then MsgBox "身份證輸入錯誤!!": Exit Sub
T = InStr("ABCDEFGHJKLMNPQRSTUVXYWZIO", Left(.Value, 1)) + 9 & Mid(.Value, 2, 8)
For i = 1 To 10
S = S + Mid(T, i, 1) * Left(11 - i, 1)
Next i
T = Right(10 - Right(S, 1), 1)
If T <> Mid(.Value, 10, 1) Then MsgBox "身份證字號錯誤!檢查碼:" & T
End With
小妹不才作者: GBKEE 時間: 2017-3-12 14:58