excel 日期查询宏的编写

来源:百度知道 编辑:UC知道 时间:2024/05/22 01:23:55
excel 中假设有C列日期都不相同,编写一个宏从中查出小于某个特定日期的所有单元格,并表注中红色

Sub tt()
On Error Resume Next
For i = 1 To Sheet1.UsedRange.Rows.Count
Dim d As Date
d = CDate(Sheet1.Cells(i, 3))
If d < #1/1/2000# Then
Sheet1.Range("c" & i).Interior.ColorIndex = 3
End If
Next i
End Sub