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

174
Views
VBA Macro extremely slow: 15 min runtime

This is my code, it takes some values from a file, looks them up in another file and pastes a value in the row where it fins those values. My file tg has 126 lines and 135 columns. My file gar_nv has 2553 lines and 67 columns. My variable nbrLines is equal to 2553. It takes 15 min to finish running. I'm wondering which part is making it so slow ? Or is it because of how big my sheets are. Thanks

Sub Remb()
Call Workbook_open

Dim acte, acte_next, Remb, Col, Col_next, produit As Variant
Dim colonne, ligne, Line, r, c As Long

With tg

   For colonne = col_dep To .UsedRange.Columns.Count
    
        For ligne = ligne_dep To nbrLines
        
            acte = tg.Range(ColName(colonne) & ligne)
            r = ligne
            c = Columns(ColName(colonne)).Column
            MsgBox (acte)
                
            
            If Not IsEmpty(acte) Then
                Remb = .Cells(r, c).Offset(0, -1).Value 
                Col = .Cells(r, c).Offset(0, 1).Value 
                produit = .Cells(6, c).Value 
                
                acte_next = .Cells(r, c).Offset(1, 0).Value
                Col_next = .Cells(r, c).Offset(1, 1).Value
                
        
                
                For Line = 1 To gar_nv.Cells(Rows.Count, 1).End(xlUp).Row
                
                    If gar_nv.Range("GCGAR6").Rows(Line).Value Like produit Then
                        If gar_nv.Range("GCBARB").Rows(Line).Value Like acte Then
                            
                           gar_nv.Range(Col).Rows(Line).Value = Remb
                           
                        End If
                    End If
                Next Line
            End If
        Next ligne
    Next colonne
End With
End Sub
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!