|
楼主 |
发表于 2020-2-2 08:55
|
显示全部楼层
老师,超过一年是,剩余天数那里计算结果显示为“已过期*天”呢,这段代码怎么改,谢谢老师
Private Sub Worksheet_Change(ByVal t As Range)
If t.Count > 1 Then Exit Sub
If t.Column = 13 And t.Row > 6 Then
If VBA.IsDate(t) Then
y = Year(t)
m = Month(t)
d = Day(t)
Application.EnableEvents = False
t.Offset(0, 1) = CDate(y + 1 & "-" & m & "-" & d)
t.Offset(0, 2) = t.Offset(0, 1) - Date
Application.EnableEvents = True
End If
If Len(t) = 0 Then
Application.EnableEvents = False
t.Offset(0, 1) = ""
t.Offset(0, 2) = ""
Application.EnableEvents = True
End If
End If
If t.Row > 6 And t.Column = 2 Then
If t.Value = "" Then Rows(t.Row).Delete: Exit Sub
Set rng = Sheets("学员信息建档").Columns(1).Find(t.Value, , , 1)
If rng Is Nothing Then MsgBox "学员信息建档中没有该电话!": Exit Sub
r = rng.Row
For j = 2 To 8
t.Offset(, j - 1) = Sheets("学员信息建档").Cells(r, j)
Next j
t.Offset(, -1) = Now()
End If
End Sub |
|