Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda