Skip to main content
deleted 17 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

This looping has no problem if I have under 100 rows in the looping table sheet. However, If it go over 100 rows, looping takes a while to filtering and paste value in looping sheet. Is there any way to optimize this VBA code to run faster?

This looping has no problem if I have under 100 rows in the looping table sheet. However, If it go over 100 rows, looping takes a while to filtering and paste value in looping sheet. Is there any way to optimize this vba code to run faster?

Thank you

This looping has no problem if I have under 100 rows in the looping table sheet. However, If it go over 100 rows, looping takes a while to filtering and paste value in looping sheet. Is there any way to optimize this vba code to run faster?

Thank you

This looping has no problem if I have under 100 rows in the looping table sheet. However, If it go over 100 rows, looping takes a while to filtering and paste value in looping sheet. Is there any way to optimize this VBA code to run faster?

Source Link

how to optimize vba looping code using variables?

Sub Testingloop()
Dim endrown As String
Dim ex As String
Dim ez As String
Dim eh As String
Dim eg As String
Dim el As String
Dim ee As String
Dim es As String
Dim ef As String
Dim ei As String
Dim i As Integer
Dim LastRowColumnA As Long: LastRowColumnA = Sheets("looping").Cells(Rows.Count, 1).End(xlUp).Row


Application.ScreenUpdating = False


Sheets("looping table").Select
endrown = Sheets("looping table").Range("I1000").End(xlUp).Row
    For i = 3 To endrown

        ee= Cells(i, 9).Value
        ex= Cells(i, 10).Value
        ez= Cells(i, 11).Value
        es = Cells(i, 12).Value
        ef = Cells(i, 13).Value
        ei = Cells(i, 14).Value
         eh = Cells(i, 15).Value
        eg= Cells(i, 16)
        el= Cells(i, 17)


        Sheets("looping").Select
             ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:=ee
             ActiveSheet.UsedRange.AutoFilter Field:=2, Criteria1:=ex
             ActiveSheet.UsedRange.AutoFilter Field:=3, Criteria1:=ez
            ActiveSheet.UsedRange.AutoFilter Field:=4, Criteria1:=es
            ActiveSheet.UsedRange.AutoFilter Field:=5, Criteria1:=ef 
             ActiveSheet.UsedRange.AutoFilter Field:=6, Criteria1:=ei
            ActiveSheet.UsedRange.AutoFilter Field:=7, Criteria1:=eh
        On Error Resume Next
        Range("H2:H" & LastRowColumnA).SpecialCells(xlCellTypeVisible).Value = eg
        Range("I2:I" & LastRowColumnA).SpecialCells(xlCellTypeVisible).Value = el
            ActiveSheet.ShowAllData
                Sheets("looping table").Select

                   Next i

End Sub

This looping has no problem if I have under 100 rows in the looping table sheet. However, If it go over 100 rows, looping takes a while to filtering and paste value in looping sheet. Is there any way to optimize this vba code to run faster?

Thank you