Ich habe ein kleines Problem!
Ich möchte mittels VBA eine Ausgabe einer msgBox haben in der doppelte Werte aus dem Zellbereich B10:H500 angezeigt werden.
Anbei meine Tabelle.
Danke für eure Hilfe!!
https://www.herber.de/bbs/user/156199.xlsm
Dim Zelle AS Range
Dim Erg AS String
Erg = vbLf
With Range("B10:H100")
For each Zelle in .Cells
If Zelle.value "" then
If Instr(Erg, vbLf & Zelle.value & vbLf) = 0 then
If worksheetfunction.countif(.cells, Zelle.value) > 1 then
Erg = Erg & Zelle.value & vbLf
End if
End if
End if
Next
If len(Erg) > 1 then
msgbox Erg
Else
Msgbox "keine Doppelten"
End if
Gruß Daniel
Option Explicit
Sub Dieter()
MsgBox SucheDoppelte(Range("B10:H500")), , "Doppelte"
End Sub
Function SucheDoppelte(rng As Range)
Dim objOUT As Object, oOBJ, strOUT As String
Dim rngC As Range
Set objOUT = CreateObject("scripting.dictionary")
For Each rngC In rng
If rngC "" Then
If objOUT.exists(rngC.Value) Then
objOUT(rngC.Value) = objOUT(rngC.Value) & "|" & rngC.Address(0, 0)
Else
objOUT(rngC.Value) = rngC.Address(0, 0)
End If
End If
Next
For Each oOBJ In objOUT
If InStr(objOUT(oOBJ), "|") Then
strOUT = strOUT & vbLf & oOBJ & ": " & objOUT(oOBJ)
End If
Next oOBJ
If Len(strOUT) Then
SucheDoppelte = strOUT
Else
SucheDoppelte = "keine Doppelten"
End If
End Function
Gruß
=UND(ZÄHLENWENN($B$10:$H$50;B10)>1;B10"")
Gruß Gerd