5,140
社区成员
发帖
与我相关
我的任务
分享
Private Sub CommandButton1_Click()
Dim iRowIndex As Integer
Dim strID As String
Dim strYear As String
iRowIndex = 1
Do While 1
strID = Sheet1.Range("A" & iRowIndex).Value
If strID = "" Then
Exit Sub
End If
If Len(strID) = 18 Then
strYear = Mid(strID, 7, 4)
ElseIf Len(strID) = 15 Then
strYear = "19" + Mid(strID, 7, 2)
End If
Sheet1.Range("B" & iRowIndex).Value = CInt(Year(Now)) - CInt(strYear)
iRowIndex = iRowIndex + 1
Loop
End Sub