Private Sub CommandButton1_Click()
Dim l As Integer
Dim y%, m%, d%
y = Year(Now())
m = Month(Now())
d = Day(Now())
Dim xdata
xdata = Date
a = Range("a65536").End(xlUp).Row - 1
l = Application.InputBox("你要删除几个月请输入", "操作提示", "0", 100, 100)
xdata = DateSerial(y, m - l, d)
For i = a To 1 Step -1 '在表格行循环
If xdata > Cells(i, 1).Value Then
Cells(i, 1).EntireRow.Delete '是的删除
Else
End If
Next
End Sub
1个颜色是1个错误,共3个。