|
原程序中调用即可。
Sub jk()
Dim h As Long
With Sheet3
i = .[a65536].End(3).Row
.Range("a2:m" & i).Sort key1:="编号", key2:="刷卡日期", Header:=xlYes
For h = i To 3 Step -1
If .Cells(h, 1) = .Cells(h - 1, 1) Then
For cs = 1 To ts(h)
.Rows(h).Insert
.Range(.Cells(h, 1), .Cells(h, 4)) = Array(.Cells(h - 1, 1), .Cells(h - 1, 2), DateAdd("d", -1, .Cells(h + cs, 3)), 0)
Next cs
End If
Next h
End With
End Sub
Function ts(h As Long) As Integer
With Sheet3
For i = 1 To 1000
t = DateAdd("d", -(i), .Cells(h, 3))
If .Cells(h - 1, 3) = t Then
ts = i - 1: Exit Function
End If
Next i
End With
End Function
|
|