I would like to please get assistance to improving speed for this particular following code because I have between 10,000 to 20,000 records.
In columns J and K are dates. In column L are integers.
Code:
Sub COMPAREMULTIPLECOLUMNS()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim j As Long, i As Long, lastrow1 As Long, lastrow2 As Long
Set sh1 = Worksheets("CURRENT")
Set sh2 = Worksheets("PREVIOUS")
lastrow1 = sh1.Cells(Rows.Count, "A").End(xlUp).Row
lastrow2 = sh2.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow1
For j = 2 To lastrow2
If sh1.Cells(i, "F").Value = sh2.Cells(j, "F").Value Then
If sh1.Cells(i, "J").Value <> sh2.Cells(j, "J").Value Then
sh1.Cells(i, "R").Value = sh2.Cells(j, "J").Value
End If
End If
If sh1.Cells(i, "F").Value = sh2.Cells(j, "F").Value Then
If sh1.Cells(i, "K").Value <> sh2.Cells(j, "K").Value Then
sh1.Cells(i, "S").Value = sh2.Cells(j, "K").Value
End If
End If
If sh1.Cells(i, "F").Value = sh2.Cells(j, "F").Value Then
If sh1.Cells(i, "L").Value <> sh2.Cells(j, "L").Value Then
sh1.Cells(i, "T").Value = sh2.Cells(j, "L").Value
End If
End If
Next j
Next i
End Sub
I would greatly appreciate any assistance.
Bookmarks