Gruppe
UDF
Problem
Die benutzerdefinierte Funktion in Zelle N1 liefert den im Wertebereich am häufigst vorkommenden Wert.
StandardModule: Modul1
Function MostValue(rngAll As Range) As Integer
Dim col As New Collection
Dim rng As Range
Dim dValue As Double
Dim iCounter As Integer
Dim iMost As Integer
On Error Resume Next
For Each rng In rngAll.Cells
col.Add rng.Value, CStr(rng.Value)
Next rng
On Error GoTo 0
For iCounter = 1 To col.Count
If WorksheetFunction.CountIf(rngAll, col(iCounter)) > iMost Then
iMost = WorksheetFunction.CountIf(rngAll, col(iCounter))
dValue = col(iCounter)
End If
Next iCounter
MostValue = dValue
End Function