Sub Doppelte_löschen()
Dim lz As Long, j As Long, i As Long
[f1,f2] = Time 'Nur zur Zeitmessung!
lz = Cells(Rows.Count, 1).End(xlUp).Row
For j = lz To 2 Step -1
If LCase(Cells(j, 3)) = LCase(Cells(j - 1, 3)) Then
'1. html stehen lassen
If LCase(Cells(j, 3)) = "html" Then
Rows(j).Delete shift:=xlUp
ElseIf LCase(Cells(j, 3)) = "jpg" Then
'letzte jpg stehen lassen
For i = j - 1 To 2
Rows(i).Delete shift:=xlUp
If LCase(Cells(i - 1, 3)) <> "jpg" Then Exit For
Next i
End If
End If
Next j
[f2] = Time 'Nur zur Zeitmessung!
End Sub
Sub Fill_It()
Cells.Delete
Cells(1).Resize(, 3) = Array("Sp1", "Sp2", "Sp3")
Cells(2, 1).Formula2 = "=CHAR(RANDARRAY(100000,,65,68,1))"
Cells(2, 2).Formula2 = _
"=CHAR(RANDARRAY(100000,,69,72,1))&INDEX({"".html"","".jpg""},RANDARRAY(100000,,1,2,1))"
Cells(2, 3).Resize(100000).Formula = "=IF(RIGHT(B2,3)=""jpg"",ROW(),1/ROW())"
With Cells(1).CurrentRegion
.Copy
.PasteSpecial xlPasteValues
.HorizontalAlignment = xlCenter
.NumberFormat = "[<1]0.000;General"
.Columns.AutoFit
End With
Application.Goto Cells(1)
End Sub
Sub letzte_Eindeutige_jpg_erste_eindeutige_html()
Dim Start#
Start = Timer
With Range("A1").CurrentRegion
.Sort .Cells(3), xlDescending, Header:=xlYes
.RemoveDuplicates Array(1, 2)
End With
With Range("A1").CurrentRegion
.Sort Range("B2"), , Range("A2"), Header:=xlYes
End With
Debug.Print Timer - Start
End Sub
Public Sub Makro9()
Dim ws As Worksheet
Dim lastRow As Long
Set ws = ActiveSheet
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
lastRow = ws.Cells(ws.Rows.count, "A").End(xlUp).row
If lastRow >= 2 Then
' Hilfsspalte
With ws.Range("E1:E" & lastRow)
.FormulaLocal = "=WENN(RECHTS(C1;3)=""jpg"";1/ZEILE();ZEILE())"
.Value = .Value
End With
' Sortierung für gewünschtes Behalten
With ws.Sort
.SortFields.Clear
.SortFields.Add ws.Range("B1:B" & lastRow), xlSortOnValues, xlAscending
.SortFields.Add ws.Range("C1:C" & lastRow), xlSortOnValues, xlAscending
.SortFields.Add ws.Range("E1:E" & lastRow), xlSortOnValues, xlDescending
.SetRange ws.Range("A1:E" & lastRow)
.Header = xlNo
.Apply
End With
' Duplikate entfernen
ws.Range("A1:E" & lastRow).RemoveDuplicates Columns:=Array(2, 3), Header:=xlNo
' Neue letzte Zeile
lastRow = ws.Cells(ws.Rows.count, "A").End(xlUp).row
' Optional zurücksortieren
With ws.Sort
.SortFields.Clear
.SortFields.Add ws.Range("D1:D" & lastRow), xlSortOnValues, xlAscending
.SortFields.Add ws.Range("C1:C" & lastRow), xlSortOnValues, xlAscending
.SetRange ws.Range("A1:E" & lastRow)
.Header = xlNo
.Apply
End With
' Hilfsspalte entfernen
ws.Columns("E").Delete
End If
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub