VBA-Code: |
Sub Auflistung() Dim Zelle As Range Dim i As Long, j As Long Dim Ergebnis As Variant i = 1 For Each Zelle In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Ergebnis = Split(Zelle, ",") For j = 0 To UBound(Ergebnis) Cells(i, 2) = Trim(Ergebnis(j)) i = i + 1 Next Next End Sub |
Option Explicit
Sub HundKatzeMaus()
On Error GoTo Fehler
Dim SP%, ZE&, LR1&, LR2&, TB1, TB2, i&, j%, A
Set TB1 = Sheets("Tabelle1")
Set TB2 = Sheets("Tabelle2")
SP = 1 'Spalte A
ZE = 1 'Zeile 1
LR1 = TB1.Cells(Rows.Count, SP).End(xlUp).Row 'letzte Zeile der Spalte
Application.ScreenUpdating = False
For i = ZE To LR1
A = Split(TB1.Cells(i, SP), ", ")
For j = 0 To UBound(A)
If WorksheetFunction.CountIf(TB2.Columns(SP), A(j)) = 0 Then 'noch nicht enthalten
LR2 = TB2.Cells(Rows.Count, SP).End(xlUp).Row + 1
TB2.Cells(LR2, SP) = A(j)
End If
Next j
Next i
Fehler:
If Err.Number <> 0 Then MsgBox "Fehler: " & Err.Number & vbLf & Err.Description: Err.Clear
End Sub