ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining biggest variable (https://www.excelbanter.com/excel-programming/290082-determining-biggest-variable.html)

Tommi[_2_]

Determining biggest variable
 
Hello!

Is there a convenient way to check in VBA, which of my 5 Long-type variables
is biggest?


-TK



Jake Marx[_3_]

Determining biggest variable
 
Hi TK,

Yes, you can use the built-in worksheet function MAX from VBA:

Sub test()
Dim l1 As Long
Dim l2 As Long
Dim l3 As Long

l1 = 1
l2 = 2
l3 = 3

MsgBox Application.WorksheetFunction.Max(l1, l2, l3)
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Tommi wrote:
Hello!

Is there a convenient way to check in VBA, which of my 5 Long-type
variables is biggest?


-TK


Tommi[_2_]

Determining biggest variable
 
Thanks Jake!

"Jake Marx" wrote in message
...
Hi TK,

Yes, you can use the built-in worksheet function MAX from VBA:

Sub test()
Dim l1 As Long
Dim l2 As Long
Dim l3 As Long

l1 = 1
l2 = 2
l3 = 3

MsgBox Application.WorksheetFunction.Max(l1, l2, l3)
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Tommi wrote:
Hello!

Is there a convenient way to check in VBA, which of my 5 Long-type
variables is biggest?


-TK





All times are GMT +1. The time now is 07:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com