Private Sub Worksheet_Activate()
Dim tablo, ub&, a, uba&, i&, j%
'---copie le tableau source---
tablo = [Tableau1].Resize(, 5) 'matrice, plus rapide
ub = UBound(tablo)
'---tableau de la feuille COMMERCES---
With [Tableau2]
.Columns(3) = "=LEN(RC[-2])" 'taille du texte en colonne A
.ListObject.Range.Sort .Cells(1, 3), xlDescending, Header:=True 'tri décroissant
.Columns(3).Delete xlToLeft
a = .Resize(, 2)
uba = UBound(a)
End With
'---remplissage des 4ème et 5ème colonnes---
For i = 1 To ub
tablo(i, 4) = "": tablo(i, 5) = "" 'RAZ de sécurité
For j = 1 To uba
If InStr(tablo(i, 3), a(j, 1)) Then _
tablo(i, 4) = a(j, 1): tablo(i, 5) = a(j, 2): Exit For
Next j, i
'---restitution---
With [Tableau3]
.Resize(ub) = tablo
.Rows(ub + 1).Resize(Rows.Count - .Rows(ub).Row).Delete xlUp 'RAZ en dessous
End With
End Sub