jeudi 31 mai 2018

Faster way to perform an If statement

Is there a faster way to run the below code? the "hr" sheet has 24000 rows and it takes about 30+ minutes to run this simple query.

Sub populateHRData17()
'APAC
Set report = ActiveWorkbook.Worksheets("Report")
Set hr = ActiveWorkbook.Worksheets("HR_Report")
Set apac = ActiveWorkbook.Worksheets("APAC_L_R")

For x = 2 To report.UsedRange.Rows.Count
    If report.Cells(x, 1) = "" Then
    End If
Next x


For i = 2 To hr.UsedRange.Rows.Count
  For j = 2 To apac.UsedRange.Rows.Count

    If apac.Cells(j, 2) = hr.Cells(i, 3) Then
       report.Cells(x, 1) = apac.Cells(j, 2)


 x = x + 1
    End If

Next j
Next i
End Sub

Aucun commentaire:

Enregistrer un commentaire