ich habe 2 Spalten mit Namen. Ich würde gerne eine MsgBox bekommen in der mir ausgegeben wird, welche Namen in Spalte 2 stehen aber nicht in Spalte 1 vorhanden sind.
Ist das ein großer Act?
Danke schonmal.
Sub aaaa()
Dim r As Range
For Each r In Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
If WorksheetFunction.CountIf(Columns(1), r) = 0 Then
MsgBox r
End If
Next
End Sub
Option Explicit
Sub Doppelt()
Dim LoLetzte As Long
Dim LoI As Long
Dim StMeldung As String
LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 2)), Cells(Rows.Count, 2).End(xlUp).Row, Rows. _
Count)
For LoI = 1 To LoLetzte
If Cells(LoI, 2) "" Then
If Application.CountIf(Columns("A"), Cells(LoI, 2)) > 0 Then
If InStr(StMeldung, Cells(LoI, 2)) = 0 Then
If StMeldung "" Then
StMeldung = StMeldung & ", "
End If
StMeldung = StMeldung & Cells(LoI, 2)
End If
End If
End If
Next LoI
MsgBox "Folgende Namebn sind enthalten " & StMeldung
End Sub
Option Explicit
Sub Doppelt()
Dim LoLetzte As Long
Dim LoI As Long
Dim StMeldung As String
LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 2)), Cells(Rows.Count, 2).End(xlUp).Row, Rows. _
Count)
For LoI = 1 To LoLetzte
If Cells(LoI, 2) "" Then
If Application.CountIf(Columns("A"), Cells(LoI, 2)) > 0 Then
If InStr(StMeldung, Cells(LoI, 2)) = 0 Then
If StMeldung "" Then
StMeldung = StMeldung & vbCrLf
End If
StMeldung = StMeldung & Cells(LoI, 2)
End If
End If
End If
Next LoI
If StMeldung "" Then MsgBox "Folgende Namen sind enthalten " & vbCrLf & StMeldung
End Sub
Gruß Hajo