es hat sich gerade wieder eine kleine Feinheit ergeben.
Gibt es die Möglichkeit, die Spalte K noch feiner zu filtern?
In der besagten Spalte steht z.B. folgende Nummer X123
456789 1011 wobei sich die Suche nach den Doppelungen nur
noch auf die 5. - 10. Stelle beziehen soll.
Hallo Melanie,
Sub Doppelte()
Dim wks1 As Worksheet, wks2 As Worksheet, wks3 As Worksheet, Formel As String
Dim Zei1 As Long, Zei2 As Long, Zei3 As Long, Spa3 As Long, strSpa3 As String
On Error GoTo hell
Set wks1 = Worksheets("Tabelle1")
Set wks2 = Worksheets("Tabelle2")
Set wks3 = Worksheets("Tabelle3")
Zei1 = wks1.Cells(wks1.Rows.Count, 11).End(xlUp).Row
Zei2 = wks2.Cells(wks2.Rows.Count, 11).End(xlUp).Row
Application.ScreenUpdating = False
With wks3
.UsedRange.ClearContents
wks1.Range("A9:smiley:A" & Zei1).Copy Destination:=.Cells(3, 100)
wks2.Range("A10:smiley:A" & Zei2).Copy Destination:=.Cells(Zei1 - 5, 100)
wks1.Range("A9:smiley:A9").Copy Destination:=.Cells(1, 100)
Spa3 = .Cells(1, Columns.Count).End(xlToLeft).Column
Zei3 = .Cells(.Rows.Count, 110).End(xlUp).Row
.Cells(1, Spa3 + 1).Value = "Blatt"
.Cells(3, Spa3 + 1).Value = "Blatt"
.Cells(1, Spa3 + 2).Value = "K2"
.Cells(3, Spa3 + 2).Value = "K2"
.Cells(1, Spa3 + 3).Value = "Zaehlen"
.Cells(3, Spa3 + 3).Value = "Zaehlen"
.Range(.Cells(4, Spa3 + 1), .Cells(Zei1 - 6, Spa3 + 1)) = wks1.Name
.Range(.Cells(Zei1 - 5, Spa3 + 1), .Cells(Zei3, Spa3 + 1)) = wks2.Name
strSpa3 = Split(.Cells(1, 110).Address, "$")(1)
.Range(.Cells(4, Spa3 + 2), .Cells(Zei3, Spa3 + 2)).Formula = "=MID(" & strSpa3 & "4,5,6)"
strSpa3 = Split(.Cells(1, Spa3 + 2).Address, "$")(1)
Formel = "=COUNTIF(" & strSpa3 & ":" & strSpa3 & "," & strSpa3 & "4)\*(" & strSpa3 & "4"""")"
.Range(.Cells(4, Spa3 + 3), .Cells(Zei3, Spa3 + 3)).Formula = Formel
.Cells(2, Spa3 + 3).Value = "\>1"
.Range(.Cells(3, 100), .Cells(Zei3, Spa3 + 3)).AdvancedFilter Action:=xlFilterCopy, \_
CriteriaRange:=.Range(.Cells(1, 100), .Cells(2, Spa3 + 3)), \_
CopyToRange:=.Cells(1, 1), Unique:=False
.Columns("CV:IV").Clear
Spa3 = .Cells(1, Columns.Count).End(xlToLeft).Column
.Columns(Spa3).Clear
.Columns(Spa3 - 1).Clear
'.Columns(Spa3 - 2).Clear
End With
hell:
Application.ScreenUpdating = True
If Err.Number 0 Then MsgBox Err.Number & vbCr & Err.Description
End Sub
Gruß
Reinhard