excel_beginer
New Member
- Joined
- Dec 28, 2017
- Messages
- 19
Hi all again
I have code belove to copy row(i) to another sheet if met conditions, it run okey with data under 50 rows but when data over 500 rows code run very slow.
Could you have some suggestions or can make this code run more faster
thanks in advanced
I have code belove to copy row(i) to another sheet if met conditions, it run okey with data under 50 rows but when data over 500 rows code run very slow.
Could you have some suggestions or can make this code run more faster
thanks in advanced
Code:
Sub Check_G02782()Worksheets("check_G02782").Range("A2:K5000").Clear
Application.ScreenUpdating = False
Dim i As Long, lastrow As Long, lastrowG02782 As Long
lastrowG02782 = Sheets("G02782").Range("A" & Rows.Count).End(xlUp).Row + 1
For i = 2 To lastrowG02782
lastrow = Sheets("check_G02782").Cells(Rows.Count, 2).End(xlUp).Row
With Sheets("G02782")
If .Cells(i, 5).Value <> 0 And .Cells(i, 7).Value <> 0 Then
.Cells(i, 10).Value = (.Cells(i, 4).Value / .Cells(i, 5).Value)
.Cells(i, 11).Value = (.Cells(i, 6).Value / .Cells(i, 7).Value)
End If
If .Cells(i, 10).Value > 1 And .Cells(i, 11).Value = 0 Then
ElseIf .Cells(i, 11).Value > 1 And .Cells(i, 10).Value = 0 Then
ElseIf .Cells(i, 10).Value < 1 Then
.Rows(i).Copy (Sheets("check_G02782").Range("A" & lastrow + 1))
ElseIf .Cells(i, 11).Value < 1 Then
.Rows(i).Copy (Sheets("check_G02782").Range("A" & lastrow + 1))
End If
End With
Next i
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: