I created this if statement as a newbie using VBA to fill out a column in an excel table. The function is functioning well, but it took close to an hour to complete. It needs to move more quickly.
2600 rows make up Table 1. 3200 rows make up Table2.
Can I help me?
Sub PreencherO()
Dim Current As Worksheet
Dim His As Worksheet
Dim Table1 As ListObject
Dim Table2 As ListObject
Set Table1 = ThisWorkbook.Worksheets("Current").ListObjects("Data")
Set Table2 = ThisWorkbook.Worksheets("His").ListObjects("Historical")
Dim irow As Long
irow = Table1.ListColumns(1).Range.Rows.Count
Dim lrow As Long
lrow = Table2.ListColumns(1).Range.Rows.Count
Dim i As Integer
Dim l As Integer
For i = 2 To irow
For l = 2 To lrow
If Table1.DataBodyRange.Cells(i, 6).Value = Table2.DataBodyRange.Cells(l, 6).Value Then
Table1.DataBodyRange.Cells(i, 20).Value = "OLD"
End If
Next l
Next i
End Sub
I need to increase the speed of it.