why doesn't vba have a min/max function?

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I just wrote a min function:

Function Min(a, b)
If a < b Then
Min = a
Else
Min = b
End If
End Function

Why can't microsoft add this?
 
Upvote 0
Why not just use the worksheetfunction?
 
Upvote 0
It slows down the program. Never use worksheet functions.

I blame microsoft. This is why people are using python instead of excel.
 
Upvote 0
It slows down the program. Never use worksheet functions.

I blame microsoft. This is why people are using python instead of excel.
Fluff meant for you to use the WorksheetFunction object which, as far as I know, is not all that slow (I use it all the time when I need Excel functionality that is not natively provided by VBA). In case you are not familiar with this object, you would call it like this...

WorksheetFunction.Min(...arg list...)

WorksheetFunction.Max(...arg list...)
 
Upvote 0
Fluff meant for you to use the WorksheetFunction object which, as far as I know, is not all that slow (I use it all the time when I need Excel functionality that is not natively provided by VBA). In case you are not familiar with this object, you would call it like this...

WorksheetFunction.Min(...arg list...)

WorksheetFunction.Max(...arg list...)

OK - I didn't know that.

I was always told that using worksheet functions was a big no no.

Thanks!
 
Upvote 0
A big no no where/when exactly?
 
Upvote 0
Read this on my mobile at work and was confused as to why it was stated that WorkSheetFunction was slow and so after getting home dug out an old laptop and done a randbetween 1,400000 over 200000 rows and got FastExcel to time running the code below

Code:
Sub testmax()
Dim X As Long
X = Application.WorksheetFunction.Max(Range("A1:A200000"))
Debug.Print X
End Sub

The result was 7.43 milliseconds, that seems reasonably fast to me.
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top