With the last twist of wanting to return the second lowest number if
there is no repeating numbers. I came up with the following code from
some posts above.
Function LowestRepeatableNumber(myRange As Range)
'This function returns the second lowest number above zero if there are
no repeating numbers
LowestRepeatableNumber = Evaluate("MIN(IF(" & myRange.Address &
">0," & "IF(COUNTIF(" & myRange.Address & "," & myRange.Address &
")>1," & _
myRange.Address & ")))")
If LowestRepeatableNumber = 0 Then LowestRepeatableNumber =
Evaluate("small(IF(" & myRange.Address & ">0," & "IF(COUNTIF(" &
myRange.Address & "," & myRange.Address & ")=1," & _
myRange.Address & ")),2)")
End Function
It works great but with one problem. I have a sheet that I use a input
box to change a number in one of the cells that this function works on.
My problem is that when I run the other macro and enter this new
number, the function runs before this new number is entered and
calculates a new number that gets used in the function. If I edit the
number again and give it the same number it all calculates right but
with this extra step. Hitting F9 to re-cacl doesnt help.
To better describe my problem, imagine cell(A1) =10 and cell(A2) =A1
* 2 this caries on for columns A-D. The function I have created finds
the lowest repeatable in the range (A2
2). When I use my macro to edit
the value in cell(A1), it enters this new value, evaluates the function
and then exits. The value of the function does not take into account
the new value in cell (A2).
Is there some way to have the formulas update before my function does?
I tried Caclulate at the end of my macro and function with no success.
THanks
Scott