bonjour,
macro adaptée pour déterminer le numéro de colonne sur base de son entête
Sub metx()
ta = " Destinataire_Nom" 'titre exact de colonne champ A
tb = "X" 'titre exact de colonne champ B
lt = 1 ' numéro de la ligne des titres de colonne
Set re = Rows(lt).Find(ta, lookat:=xlWhole)
If re Is Nothing Then MsgBox "titre de colonne " & ta & " non trouvé": Exit Sub
a = re.Column
Set re = Rows(1).Find(tb, lookat:=xlWhole)
If re Is Nothing Then MsgBox "titre de colonne " & tb & " non trouvé": Exit Sub
b = re.Column
dl = Cells(Rows.Count, a).End(xlUp).Row
For i = 2 To dl
If Cells(i, a) <> Cells(i + 1, a) Then Cells(i, b) = "X"
Next i
End Sub
SMPSS a écrit :
Super, merci bigdaddy154 !
Ce qui, vu que :
- ma colonne Destinataire_Nom est en colonne M, soit la 13ème ;
- ma colonne X est en colonne R, soit la 18ème ;
, me donne donc :
Sub Macro()
a = 13
b = 18
dl = Cells(Rows.Count, a).End(xlUp).Row
For i = 2 To dl
If Cells(i, a) <> Cells(i + 1, a) Then Cells(i, b) = "X"
Next i
End Sub
Ce qui en faisant F5 me permet d'arriver au résultat escompté, avec la valeur X pour le champ X à chaque dernière occurrence d'une valeur donnée au champ Destinataire_Nom.
Merci à vous !
tu pouvais aussi mettre l'identifiant de la colonne plutôt que son numéro
Sub Macro()
a = "M"
b = "R"
dl = Cells(Rows.Count, a).End(xlUp).Row
For i = 2 To dl
If Cells(i, a) <> Cells(i + 1, a) Then Cells(i, b) = "X"
Next i
End Sub