Can some expert enlighten me, how can the below code take 4secs to run? Btw i am using a timer to check the below code and it took me 4secs to run just this little stuff. Btw the lastrow will never exceed 1000 rows
Sub rows_insert()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.DisplayStatusBar = False
.Calculation = xlCalculationManual
End With
'Place your macro code here''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim x As Integer
Dim i As Integer
Dim lastROW As Long
lastROW = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
For i = 29 To lastROW
If Cells(i, 3).Value = "HELLO" Then
Rows(i).EntireRow.Delete
i = i - 1
End If
Next i
For x = 2 To 26
If Cells(x, 9) <> "" Then
Range("40:40").Insert
Range("A40:AD40").Interior.Color = RGB(180, 150, 250)
Cells(40, 3) = "HELLO"
Cells(40, 7).Value = Cells(x, 7).Value 'Data A
Cells(40, 8).Value = Cells(x, 10).Value 'Data B
Cells(40, 19).Value = Cells(x, 8).Value 'Data C
Cells(40, 21).Value = Cells(x, 9).Value 'Data D
Cells(40, 1).Value = "Ok"
Cells(40, 26).Value = Cells(x, 11).Value 'Data E
End If
Next x
Range("A28:AE900").Sort key1:=Range("G28"), order1:=xlAscending, Header:=xlYes
ThisWorkbook.Save
'end of macro''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.DisplayStatusBar = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Display More