我有这个问题,我想从我自己中减去两个日期,但我仍然有运行时错误13,输入错误。今天的任务是从单元格中减去日期(单元格格式:日期)。我可以用今天的日期创建一个单元格,但我不想这样做。
Dim i As Long, j As Long
Dim ark5 As Worksheet
Set ark5 = Worksheets("Zalegle")
Dim LastRow5 As Long
Dim a As Date
LastRow5 = ark5.Cells(Rows.Count, 2).End(xlUp).Row
a = DateDiff("d", Now, ark5.Cells(2, "G"))
For i = LastRow5 To 2 Step (-1)
If Date - a < 7 Then
Rows(i).EntireRow.Delete
i = i - 1
End If
Next i
End Sub```发布于 2020-05-12 21:12:16
使用CDate可能会解决你的问题,试试这个:
Dim i As Long, j As Long
Dim ark5 As Worksheet
Set ark5 = Worksheets("Zalegle")
Dim LastRow5 As Long
Dim a As Date
LastRow5 = ark5.Cells(Rows.Count, 2).End(xlUp).Row
a = DateDiff("d", Now, CDate(ark5.Cells(2, "G").value))
For i = LastRow5 To 2 Step (-1)
If Date - a < 7 Then
Rows(i).EntireRow.Delete
End If
Next i
End Sub```https://stackoverflow.com/questions/61752530
复制相似问题