Private Sub CommandButton1_Click()
Sheet1.Range("B4:I9999").ClearContents
arr = Sheet2.Cells(1, 1).CurrentRegion
StartDate = Sheet1.Cells(1, 3)
EndDate = Sheet1.Cells(1, 5)
If Not IsDate(StartDate) Then MsgBox "开始日期不正确,请重新输入。": Sheet1.Cells(1, 3).Select: Exit Sub
'同样原理,你自己写判断
tmpRow = 3
For i = 2 To UBound(arr)
tmpDate = DateSerial(Left(arr(i, 2), 4), Mid(arr(i, 2), 5, 2), Mid(arr(i, 2), 7, 2))
If tmpDate >= StartDate And tmpDate <= EndDate Then
tmpRow = tmpRow + 1
With Sheet1
.Cells(tmpRow, 2) = tmpDate
.Cells(tmpRow, 3) = arr(i, 2)
.Cells(tmpRow, 4) = arr(i, 3)
.Cells(tmpRow, 5) = arr(i, 4)
.Cells(tmpRow, 6) = arr(i, 8)
.Cells(tmpRow, 7) = arr(i, 9)
.Cells(tmpRow, 8) = arr(i, 15)
.Cells(tmpRow, 9) = arr(i, 13)
End With
End If
Next i
End Sub |