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

MetLife

Active Member
Joined
Jul 2, 2012
Messages
334
Office Version
  1. 365
Why is it so difficult to just add this to the library?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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