Silverjman
Board Regular
- Joined
- Mar 19, 2014
- Messages
- 110
Hello,
I have a grid that is 4814 rows by 40 columns and need to do a simple NON Worksheetfunction MIN function.
From my googling this seems to be the best solution but I can't get the code to work.
Any idea whay I'm getting a Type 13 mismatch with this?
If I move the "minValue = Value" down to the next line I get a "Next without For" error?
Any help much appreciated
I have a grid that is 4814 rows by 40 columns and need to do a simple NON Worksheetfunction MIN function.
From my googling this seems to be the best solution but I can't get the code to work.
max min VBA
How do I get maximum of two numbers in VBA lets say I have var1 = 2 var2 = 30 I want to compare the 2 and get the maximum so maybe something like this. (but i know this doesnt work) result = max(var1, var2)
www.mrexcel.com
VBA Code:
Function Min(ParamArray values() As Variant) As Variant
Dim minValue, Value As Variant
minValue = values(0)
For Each Value In values
If Value < minValue Then minValue = Value
Next
Min = minValue
End Function
Any idea whay I'm getting a Type 13 mismatch with this?
If I move the "minValue = Value" down to the next line I get a "Next without For" error?
Any help much appreciated
Last edited by a moderator: