I want to find the number having repeated time is max in the range which is limited by min and max number. So I try to develop a function but it can not run.
Help me pls,
Thank you so much
Function xxx(x As Integer, y As Integer, dl As Variant) As Integer
Dim a As Integer, b As Integer
ReDim DL2(1 To UBound(dl), 1 To 2)
Set Dic = CreateObject("Scripting.Dictionary")
With Dic
a = 1
For j = 1 To UBound(dl, 2)
For i = 1 To UBound(dl, 1)
Tmp = dl(i, j)
If Tmp >= x And Tmp <= y Then
If Not .exists(Tmp) Then
k = k + 1
.Add Tmp, k
DL2(k, 1) = dl(i, j)
DL2(k, 2) = 1
Else
Rws = Dic.Item(Tmp)
DL2(Rws, 2) = DL2(Rws, 2) + 1
If DL2(Rws, 2) >= a Then
a = DL2(Rws, 2)
b = DL2(Rws, 1)
End If
End If
End If
Next
Next
End With
xxx = b
End Function
Bookmarks