macro doublon - macro plante si trop de lignes!

VBA_DEAD

XLDnaute Occasionnel
Bonjour

J`espère que tout le monde va bien.
J`ai une macro pour identifier les doublons…et elle marche bien.

Sub doublonTR2()
Dim a As Integer
Dim i As Integer

With Worksheets("TR2")
x = Range("A65536").End(xlUp).Row
End With

Range("A1:N" & x & "").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
For i = 2 To x
If Cells(i, 2) = Cells(i + 1, 2) And Cells(i, 9) = Cells(i + 1, 9) And Cells(i, 14) = Cells(i + 1, 14) Then
‘Va chercher doublon ds col B,I et N

Cells(i, 1).EntireRow.Select
With Selection.Interior
.ColorIndex = 15
End With
Cells(i + 1, 1).EntireRow.Select
With Selection.Interior
.ColorIndex = 15
End With

End If
Next i

End Sub

Je ne peux pas coller le fichier il est trop gros!

Mais elle ne marche pas si j`ai 55000 lignes ce qui est mon cas.
Je cherche les doublons mais au dela d`un certain nombre d eligne elle marche plus.

Quelqu`nu comprend pourquoi ?
Quelqu`un aurait il une autre solution du type si doublon ca met un « D » ds la col de droite (charge a moi de filtrer) ou autre

Merci

Sinon bonne journee quand meme

VBA_DEAD
 

porcinet82

XLDnaute Barbatruc
Re : macro doublon - macro plante si trop de lignes!

Salut,

En plus de la réponse de JeanPierre, j'ai fait quelques modif a ton code, il manquait surtout le point dans ton premier With :
Code:
Sub doublonTR2()
Dim a&
Dim i&
Dim x&
With Worksheets("TR2")
    x = .Range("A65536").End(xlUp).Row
End With
Range("A1:N" & x).Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
For i = 2 To x
    If Cells(i, 2) = Cells(i + 1, 2) And Cells(i, 9) = Cells(i + 1, 9) And Cells(i, 14) = Cells(i + 1, 14) Then
        'Va chercher doublon ds col B,I et N
        Cells(i, 1).EntireRow.Interior.ColorIndex = 15
        Cells(i + 1, 1).EntireRow.Interior.ColorIndex = 15
    End If
Next i
End Sub

@+
 

VBA_DEAD

XLDnaute Occasionnel
Re : macro doublon - macro plante si trop de lignes!

bonjour Jean pierre & Porcinet (j`adore ce nom..souvenir, souvenir,

merci pour le lien. ca marche!

Porcinet, je regarde ton code. c`est marrant la macro marche quand meme

Merci a tous les 2 pour voter aide

au plaisir

VBA_DEAD
 

ChTi160

XLDnaute Barbatruc
Re : macro doublon - macro plante si trop de lignes!

Salut VBA_DEAD
histoire de Saluer le fil
pourquoi pas plus de points en déplaçant Le End With
Code:
Sub doublonTR2()
Dim a&
Dim i&
Dim x&
With Worksheets("TR2")
    x = [COLOR=red].[/COLOR]Range("A65536").End(xlUp).Row
[COLOR=red].[/COLOR]Range("A1:N" & x).Sort Key1:=[COLOR=red].[/COLOR]Range("A2"), Order1:=xlAscending, _
      Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
                                        Orientation:=xlTopToBottom
For i = 2 To x
    If [COLOR=red].[/COLOR]Cells(i, 2) = [COLOR=red].[/COLOR]Cells(i + 1, 2) And [COLOR=red].[/COLOR]Cells(i, 9) = [COLOR=red].[/COLOR]Cells(i + 1, 9) And _
                                     [COLOR=red] .[/COLOR]Cells(i, 14) =[COLOR=red] .[/COLOR]Cells(i + 1, 14) Then
        'Va chercher doublon ds col B,I et N
       [COLOR=red].[/COLOR]Cells(i, 1).EntireRow.Interior.ColorIndex = 15
       [COLOR=red].[/COLOR]Cells(i + 1, 1).EntireRow.Interior.ColorIndex = 15
    End If
Next i
[COLOR=red]End With[/COLOR]
End Sub
Bonne fin de Journée
 

Discussions similaires

Réponses
0
Affichages
265
Réponses
1
Affichages
322

Statistiques des forums

Discussions
313 769
Messages
2 102 234
Membres
108 181
dernier inscrit
Chr1sD