Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Faster way to loop through large transaction lists

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:

  • Exact match (exact same string of concatenated row in both sheets)
  • Partial match (not exact same string, but same document number in both sheets)
  • No match (no exact string, no exact doc number in other sheet)

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.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!