Bonjour
J'essai de comparer deux colonnes.
Dans la deuxième colonne certains noms ne sont pas complets et finisssent par des points
Donc j'enlève les points de la colonne B et je compare ce qui reste avec le même nombre de caractère de la colonne A
Cela fonctionne pour certains noms, pas pour d'autres
En comparant manuelement on dirait pourtant que c'est la même chose
merci
Sub Remplace_Noms()
Application.ScreenUpdating = False
Bd_1 = [A51].Row
Bd_2 = [B51].Row
For i = 1 To Bd_1
For j = 1 To Bd_2
t_1 = Cells(i, 1)
t_2 = Cells(j, 2)
t_2 = Replace(t_2, ".", "")
NB_Caract_BD_1 = Len(t_1)
NB_Caract_BD_2 = Len(t_2)
If Left(t_1, NB_Caract_BD_2) = Left(t_2, NB_Caract_BD_2) Then
Cells(i, 1).Offset(0, 5) = t_1 'Left(t_1, NB_Caract_BD_2)
Cells(i, 1).Offset(0, 6) = NB_Caract_BD_1
Cells(j, 2).Offset(0, 6) = t_2 'Left(t_2, NB_Caract_BD_2)
Cells(j, 2).Offset(0, 7) = NB_Caract_BD_2
Next
Next
Application.ScreenUpdating = True
End Sub
J'essai de comparer deux colonnes.
Dans la deuxième colonne certains noms ne sont pas complets et finisssent par des points
Donc j'enlève les points de la colonne B et je compare ce qui reste avec le même nombre de caractère de la colonne A
Cela fonctionne pour certains noms, pas pour d'autres
En comparant manuelement on dirait pourtant que c'est la même chose
merci
Sub Remplace_Noms()
Application.ScreenUpdating = False
Bd_1 = [A51].Row
Bd_2 = [B51].Row
For i = 1 To Bd_1
For j = 1 To Bd_2
t_1 = Cells(i, 1)
t_2 = Cells(j, 2)
t_2 = Replace(t_2, ".", "")
NB_Caract_BD_1 = Len(t_1)
NB_Caract_BD_2 = Len(t_2)
If Left(t_1, NB_Caract_BD_2) = Left(t_2, NB_Caract_BD_2) Then
Cells(i, 1).Offset(0, 5) = t_1 'Left(t_1, NB_Caract_BD_2)
Cells(i, 1).Offset(0, 6) = NB_Caract_BD_1
Cells(j, 2).Offset(0, 6) = t_2 'Left(t_2, NB_Caract_BD_2)
Cells(j, 2).Offset(0, 7) = NB_Caract_BD_2
Next
Next
Application.ScreenUpdating = True
End Sub