Bonjour bouben
Merci, ça fonctionne
J'ai une petite question tout de même. J'aimerai adapter le code car en réalité, j'ai 2 fichiers excel :
- 1 fichier source où se trouve la base de données
- et un fichier cible où vont s'écrire les informations
j'ai donc remplacé ça :
For iLig2 = 2 To iDerLig2
sCommercial = ""
dtMax = "01/01/1900"
For iLig1 = 2 To iDerLig1
If Range("A" & iLig1).Value = Range("L" & iLig2).Value Then
If DateDiff("d", dtMax, Range("H" & iLig1).Value) > 0 Then
dtMax = Range("H" & iLig1).Value
sCommercial = Range("E" & iLig1).Value
End If
End If
Next iLig1
Range("M" & iLig2).Value = sCommercial
Next iLig2
par ceci :
For Each cell2 In Pl2
sCommercial = ""
dtMax = "01/01/1900"
'For iLig1 = 4 To iDerLig1
For Each cell1 In Pl1
If cell1 = cell2 Then
If DateDiff("d", dtMax, Range("H" & iLig1).Value) > 0 Then 'a mod..
dtMax = Range("H" & iLig1).Value
sCommercial = Range("E" & iLig1).Value
End If
End If
Next cell1
Range("H" & iLig2).Value = sCommercial
Next cell2
mais il y a un truc qu'il n’apprécie pas