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