Doublon dans une ligne

highlander

XLDnaute Nouveau
Bonjour, ja'imerai un peu d'aide

Je voudrais faire en VBA (pas en miuse en forme conditionnelle) un petit programme qui reperererai les doublon sur une ligne
de c4 à ac4.
Si il trouve un doublon, il doit le mettre en couleur (rouge).

Puis le programme doit ensuite passer au ligne suivantes jusqua la ligne 42

Autre posibilité, marqué dans la colonne AD "doublon" si il ya un doublon dans la ligne

si quelqu'un a une idée merci
 

job75

XLDnaute Barbatruc
Re : Doublon dans une ligne

Bonjour highlander,

Code:
Sub Doublons()
Dim plage As Range, cel As Range
Application.ScreenUpdating = False
Set plage = Range("C4:AC42")
plage.Interior.ColorIndex = xlNone
For Each cel In plage
If Application.CountIf(Range(Cells(cel.Row, "C"), Cells(cel.Row, "AC")), cel) > 1 _
  Then cel.Interior.ColorIndex = 3 'couleur rouge
Next
End Sub

Edition : cette variante :

Code:
Sub Doublons()
Dim plage As Range, cel As Range
Application.ScreenUpdating = False
Set plage = Range("C4:AC42")
plage.Interior.ColorIndex = xlNone
For Each cel In plage
If Application.CountIf([COLOR="Red"]plage.Rows(cel.Row - 3)[/COLOR], cel) > 1 _
  Then cel.Interior.ColorIndex = 3 'couleur rouge
Next
End Sub

A+
 
Dernière édition:

job75

XLDnaute Barbatruc
Re : Doublon dans une ligne

Re,

L'autre possibilité souhaitée :

Code:
Sub Doublons()
Dim cel As Range
Application.ScreenUpdating = False
Range("AD4:AD42").ClearContents
For Each cel In Range("C4:AC42")
If Application.CountIf(Range(Cells(cel.Row, "C"), Cells(cel.Row, "AC")), cel) > 1 _
  Then Cells(cel.Row, "AD") = "doublon"
Next
End Sub

A+
 

Discussions similaires

Réponses
22
Affichages
887
Réponses
26
Affichages
989

Statistiques des forums

Discussions
312 506
Messages
2 089 127
Membres
104 042
dernier inscrit
tropsy89