Sub SupprimeDoublons()
Dim d As Object, i&, x$
Set d = CreateObject("Scripting.Dictionary")
d.comparemode = vbTextCompare 'la casse est ignorée
Application.ScreenUpdating = False
For i = Range("K" & Rows.Count).End(xlUp).Row To 1 Step -1
x = Cells(i, 11) & Cells(i, 12)
If x <> "" Then If d.exists(x) Then Rows(i).Resize(5).Delete Else d(x) = ""
Next
End Sub
Sub SupprimeDoublons()
Dim t#, d As Object, derlig&, i&, x$
t = Timer
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
Application.ScreenUpdating = False
derlig = Range("K" & Rows.Count).End(xlUp).Row
With Range("M1:M" & derlig) 'colonne auxiliaire
.Value = 1
For i = derlig To 1 Step -1
x = Cells(i, 11) & Cells(i, 12)
If x <> "" Then If d.exists(x) Then Cells(i, 13).Resize(5) = "a" Else d(x) = ""
Next
.EntireRow.Sort .Cells(1), xlAscending, Header:=xlNo 'tri pour accélérer
On Error Resume Next 's'il n'y a pas de SpecialCell
.SpecialCells(xlCellTypeConstants, 2).EntireRow.Delete
.Value = ""
End With
With ActiveSheet.UsedRange: End With 'actualise les barres de défilement
Application.ScreenUpdating = True
MsgBox "Durée " & Format(Timer - t, "0.00\s") 'mesure facultative
End Sub
merci énormémentRe,
J'ai créé le fichier joint de 25 000 lignes.
La macro précédente ne s'en sort pas, j'ai quitté par le Gestionnaire des tâches.
Alors j'ai écrit cette macro :
Chez moi sur Win 10 - Excel 2013 elle s'exécute en 11,4 secondes, c'est acceptable.Code:Sub SupprimeDoublons() Dim t#, d As Object, derlig&, i&, x$ t = Timer Set d = CreateObject("Scripting.Dictionary") d.CompareMode = vbTextCompare 'la casse est ignorée Application.ScreenUpdating = False derlig = Range("K" & Rows.Count).End(xlUp).Row With Range("M1:M" & derlig) 'colonne auxiliaire .Value = 1 For i = derlig To 1 Step -1 x = Cells(i, 11) & Cells(i, 12) If x <> "" Then If d.exists(x) Then Cells(i, 13).Resize(5) = "a" Else d(x) = "" Next .EntireRow.Sort .Cells(1), xlAscending, Header:=xlNo 'tri pour accélérer On Error Resume Next 's'il n'y a pas de SpecialCell .SpecialCells(xlCellTypeConstants, 2).EntireRow.Delete .Value = "" End With With ActiveSheet.UsedRange: End With 'actualise les barres de défilement Application.ScreenUpdating = True MsgBox "Durée " & Format(Timer - t, "0.00\s") 'mesure facultative End Sub
A+
Sub CopieShape()
Dim c As Range, i&
Application.ScreenUpdating = False
Set c = [D6] 'puis D7
Selection.Copy 'selectionner au préalable la flèche de la cellule c
For i = 1 To 4999
ActiveSheet.Paste
Selection.Top = c.Offset(5 * i).Top + c.Offset(5 * i).Height / 2
Selection.Left = c.Left + 2
Next
End Sub
Range("B5:C" & derlig).UnMerge 'défusionne les cellules en colonnes B:C
'-----
Intersect([B:C], [L:L].SpecialCells(xlCellTypeConstants, 2).EntireRow).Merge 'refusionne
Re,
Dans ce fichier (3) les cellules telles que B5:C5, B10:C10... sont fusionnées.
Leur traitement est très simple :
La durée d'exécution de la macro passe à 6,4 secondes.Code:Range("B5:C" & derlig).UnMerge 'défusionne les cellules en colonnes B:C '----- Intersect([B:C], [L:L].SpecialCells(xlCellTypeConstants, 2).EntireRow).Merge 'refusionne
A+
Sub SupprimeDoublons()
'se lance par les touches Ctrl+D
Dim t#, d As Object, i&, x$, n&
t = Timer
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
Application.ScreenUpdating = False
For i = Range("K" & Rows.Count).End(xlUp).Row To 4 Step -1
If IsDate(Cells(i, 10)) And Cells(i, 11) <> "" And Cells(i, 12) <> "" Then
x = Int(Cells(i, 10)) & Cells(i, 11) & Cells(i, 12)
If d.exists(x) Then Rows(i).Resize(6).Delete: n = n + 1 Else d(x) = ""
End If
Next
With ActiveSheet.UsedRange: End With 'actualise la barre de défilement verticale
Application.ScreenUpdating = True
MsgBox n & " zones de 6 lignes supprimées en " & Format(Timer - t, "0.00 \s")
End Sub
Sub SupprimeDoublons()
'se lance par les touches Ctrl+D
Dim t#, d As Object, derlig&, i&, x$, n&
t = Timer
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
Application.ScreenUpdating = False
derlig = Range("K" & Rows.Count).End(xlUp).Row
Range("B4:C" & derlig).UnMerge 'défusionne les cellules en colonnes B:C
With Range("X4:X" & derlig) 'colonne auxiliaire
.Value = 1
For i = derlig To 4 Step -1
If IsDate(Cells(i, 10)) And Cells(i, 11) <> "" And Cells(i, 12) <> "" Then
x = Int(Cells(i, 10)) & Cells(i, 11) & Cells(i, 12)
If d.exists(x) Then Cells(i, 24).Resize(6) = "a": n = n + 1 Else d(x) = ""
End If
Next
.EntireRow.Sort .Cells(1), xlAscending, Header:=xlNo 'tri pour accélérer
On Error Resume Next 's'il n'y a pas de SpecialCell
.SpecialCells(xlCellTypeConstants, 2).EntireRow.Delete
.Value = ""
End With
[D:D].Replace "du", 0
Intersect([B:C], [D:D].SpecialCells(xlCellTypeConstants, 1).EntireRow).Merge 'refusionne
[D:D].Replace 0, "du"
With ActiveSheet.UsedRange: End With 'actualise les barres de défilement
Application.ScreenUpdating = True
MsgBox n & " zones de 6 lignes supprimées en " & Format(Timer - t, "0.00 \s")
End Sub