I created an array to speed up this but it seems to take forever to run still. Is there are way to say once the first If is satisfied move to next i? It seems to find the match (always only one) but still search through all of the annualArray.
Do give detail i have ID's on one table and want to find the matching ID on another table, then pull the date from the second table and put it into the first table (and subtract by todays date)
Set report = ActiveWorkbook.Worksheets("Report")
Set uwat = ActiveWorkbook.Worksheets("UWAT")
For i = 2 To report.UsedRange.Rows.Count
For Z = 2 To annual.UsedRange.Rows.Count
annualArray1 = Worksheets("Annual").Range("B1:T2000").Value
If CLng(report.Cells(i, 1)) = annualArray1(Z, 1) And annualArray1(Z, 19) <> "" Then
report.Cells(i, 19) = Date - CDate(Mid(annualArray1(Z, 19), 16, 10))
End If
Next Z
Next i
Aucun commentaire:
Enregistrer un commentaire