|
Sub 周排课表()
Dim ar As Variant
Dim br()
Dim i As Long
ar = Sheet1.[a1].CurrentRegion
With ActiveSheet
ks = .[l1]
js = .[n1]
If Not IsDate(ks) Or Not IsDate(js) Then MsgBox "请输入日期": Exit Sub
For i = UBound(ar) To 2 Step -1
If Trim(ar(i, 14)) <> "" Then
xh = i
Exit For
End If
Next i
If xh = "" Then
xh = UBound(ar)
Else
xh = xh
End If
ReDim br(1 To UBound(ar), 1 To 9)
For i = 2 To xh
If IsDate(ar(i, 6)) Then
rq = ar(i, 6) + 7
If DateValue(rq) >= DateValue(ks) And DateValue(rq) <= DateValue(js) Then
n = n + 1
For j = 2 To 10
If j <> 6 Then
br(n, j - 1) = ar(i, j)
End If
Next j
br(n, 5) = rq
End If
End If
Next i
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, UBound(br, 2)) = br
End With
MsgBox "ok!"
End Sub
|
|