|
楼主 |
发表于 2024-10-18 13:17
|
显示全部楼层
这是AI给改的代码,计算照样超慢
Sub test2()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim lastRow As Long
Dim dataArray() As Variant
Dim i As Long
Set ws = ThisWorkbook.Sheets("OPO")
lastRow = ws.Cells(ws.Rows.Count, "f").End(xlUp).Row
ReDim dataArray(1 To lastRow, 1 To 5)
For i = 2 To lastRow
dataArray(i, 1) = Replace(ws.Cells(i, "l") & ws.Cells(i, "m"), " ", "")
dataArray(i, 2) = ws.Cells(i, "ae") - ws.Cells(i, "p")
dataArray(i, 3) = ws.Cells(i, "q") - ws.Cells(i, "b")
dataArray(i, 4) = IIf(Date > ws.Cells(i, "t"), "Y", "N")
dataArray(i, 5) = Format(Year(ws.Cells(i, "t")) & DatePart("ww", ws.Cells(i, "t")))
Next i
For i = 2 To lastRow
ws.Cells(i, 1) = dataArray(i, 1)
ws.Cells(i, 2) = dataArray(i, 2)
ws.Cells(i, 3) = dataArray(i, 3)
ws.Cells(i, 4) = dataArray(i, 4)
ws.Cells(i, 5) = dataArray(i, 5)
Next i
Application.ScreenUpdating = True
End Sub |
|