VBA 导致 excel 滞后的代码

VBA code causing excel lagging

我下面的代码用于根据输入的第一个日期递减日期,如果 B 列已填充。由于导入到 Excel 的数据非常大,所以这个计算现在导致我的 excel 滞后。有什么办法可以加快速度吗??

For i = 1 To rowNow - 3

newDate = DateAdd("d", -i, oldDate)

For Each Cell In Range("A:A").Cells

If IsEmpty(Cell) = True And IsEmpty(Range("B:B")) = False Then Cell.Value = newDate: Exit For

Next
Next

也许是这样,取决于 B 列中的内容:

For i = 1 To rowNow - 3
    newDate = DateAdd("d", -i, oldDate)
    With Range("A:A")
        On Error Resume Next
        Intersect(.SpecialCells(xlCellTypeBlanks), .Offset(, 1).SpecialCells(xlCellTypeConstants).Offset(, -1))(1).Value = newDate
    End With
Next i