View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Lowest repeatable number in a range

Looks like a reasonable approach to me.

--
Regards,
Tom Ogilvy



"Riddler" wrote:

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