Mackeral
Board Regular
- Joined
- Mar 7, 2015
- Messages
- 232
- Office Version
- 365
- Platform
- Windows
I needed code to use string arguments for these arithmetic functions, so added a little code.
Mac
VBA Code:
Function Mini(ParamArray values())
' Return smalest "Value"
' 12/18/20 Copied form MrExcel.Com, "Passing UDF w ParamArray". WML
Mini = values(0)
For Each Value In values
Call Is_Number(Value)
If TypeName(Value) = "String" Then Value = CDbl(Value)
If Value < Mini Then Mini = Value
Next
End Function ' Mini
Function Maxi(ParamArray values() As Variant) As Variant
' 12/18/20 Copied form MrExcel.Com, "Passing UDF w ParamArray". WML
Maxi = values(0)
For Each Value In values
Call Is_Number(Value)
If TypeName(Value) = "String" Then Value = CDbl(Value)
If Value > Maxi Then Maxi = Value
Next
End Function ' Maxi
Sub Is_Number(Value)
' Test that "Value" is a number.
' 12/18/20 WML
Const Test_Values = "123456789."
Is_Number = True
For i = 1 To Len(Value)
Char = Mid(Value, i, 1)
If InStr(Test_Values, Char) = 0 Then
If Trace() Then ' < -- a Function returning True or False from NAMES
Stop
Else
End
End If
End If
Next i
End Sub ' Min_Max_Test
Mac
Last edited: