Objective: I am building the a macro below with the intention comparing what has changed in a transaction list (TL) as it grows with ongoing posting of new transactions. I want to know exactly what has changed between the new TL and the old TL, so that Old TL + Changes = New TL...
How I did it so far: The method is to flag transactions in 2 separate sheets (old TL, new TL) with same columns layout filled with transactions as follows:
Challenge: My code runs but with 50,000 records between the sheets it takes about 15 minutes
Question: Does anyone have a suggestion how I could make the code below run faster (extract) - where all variables are ranges except nrws and cls which is are doubles.
For l = 2 To nrws
Set nkey = nTL.Cells(l, cls + 1)
Set ndoc = nTL.Cells(l, 5)
nTL.Cells(l, cls + 2) = Application.WorksheetFunction.CountIf(nkeyList, nkey)
nTL.Cells(l, cls + 3) = Application.WorksheetFunction.CountIf(okeyList, nkey)
nTL.Cells(l, cls + 4) = Application.WorksheetFunction.CountIf(ndocList, ndoc)
nTL.Cells(l, cls + 5) = Application.WorksheetFunction.CountIf(odocList, ndoc)
If nTL.Cells(l, cls + 3) = 0 Then
If nTL.Cells(l, cls + 5) = 0 Then
nTL.Cells(l, cls + 6) = "No Match"
Else: nTL.Cells(l, cls + 6) = "Partial Match"
End If
ElseIf nTL.Cells(l, cls + 2) = nTL.Cells(l, cls + 3) And nTL.Cells(l, cls + 4) = nTL.Cells(l, cls + 5) Then
nTL.Cells(l, cls + 6) = "Exact Match"
ElseIf nTL.Cells(l, cls + 2) = nTL.Cells(l, cls + 3) Then
nTL.Cells(l, cls + 6) = "Partial Match"
Else
nTL.Cells(l, cls + 6) = "Check"
End If
Next l
Thanks in advance - Let me know if I omitted something.