R
Riddler
I am trying to come up with a function or some way to return the lowest
repeatable number in a range of numbers. Here is a function that I
have. It works but does not look pretty. Does anyone have a better
routine or idea to acomplish this?
Thanks
Scott
Function LowestRepeatableNumber(myRange As Range)
Dim LastCount As Integer
Dim LowestNumber
LastCount = 0
LowestNumber = Application.WorksheetFunction.Max(myRange)
For Each Value In myRange
If Value = 0 Then GoTo 10
b = Application.WorksheetFunction.CountIf(myRange, Value)
If b > 2 And Value < LowestNumber Then
LowestNumber = Value
End If
10 Next Value
LowestRepeatableNumber = LowestNumber
End Function
repeatable number in a range of numbers. Here is a function that I
have. It works but does not look pretty. Does anyone have a better
routine or idea to acomplish this?
Thanks
Scott
Function LowestRepeatableNumber(myRange As Range)
Dim LastCount As Integer
Dim LowestNumber
LastCount = 0
LowestNumber = Application.WorksheetFunction.Max(myRange)
For Each Value In myRange
If Value = 0 Then GoTo 10
b = Application.WorksheetFunction.CountIf(myRange, Value)
If b > 2 And Value < LowestNumber Then
LowestNumber = Value
End If
10 Next Value
LowestRepeatableNumber = LowestNumber
End Function