![]() |
Max of integer vals
Hello, How do I take the max of 2 integer values in VBA? (I'd like to set variable = to the max of itself and a cell reference which contains a int) Thank you -- jbl2 ----------------------------------------------------------------------- jbl25's Profile: http://www.excelforum.com/member.php...nfo&userid=722 View this thread: http://www.excelforum.com/showthread.php?threadid=26488 |
Max of integer vals
One way:
Sub test() ' put a value in cell B3, say 10 Dim i As Long i = 3 i = WorksheetFunction.Max(i, Range("B3")) MsgBox i End Sub Regards Trevor "jbl25" wrote in message ... Hello, How do I take the max of 2 integer values in VBA? (I'd like to set a variable = to the max of itself and a cell reference which contains an int) Thank you! -- jbl25 ------------------------------------------------------------------------ jbl25's Profile: http://www.excelforum.com/member.php...fo&userid=7225 View this thread: http://www.excelforum.com/showthread...hreadid=264883 |
Max of integer vals
Hi
use application.worksheetfunction.max(...) -- Regards Frank Kabel Frankfurt, Germany "jbl25" schrieb im Newsbeitrag ... Hello, How do I take the max of 2 integer values in VBA? (I'd like to set a variable = to the max of itself and a cell reference which contains an int) Thank you! -- jbl25 --------------------------------------------------------------------- --- jbl25's Profile: http://www.excelforum.com/member.php...fo&userid=7225 View this thread: http://www.excelforum.com/showthread...hreadid=264883 |
Max of integer vals
If you only do 2
Dim intVal as integer, intMax as Integer intVal = int(rnd() * 2 * Range("B9").Value + 1) if intVal Range("B9").value then intMax = intValue Else intMax = Range("B9").Value End if or use the immediate IF intMax = iif(intValRange("B9"),intVal,Range("B9")) -- Regards, Tom Ogilvy "jbl25" wrote in message ... Hello, How do I take the max of 2 integer values in VBA? (I'd like to set a variable = to the max of itself and a cell reference which contains an int) Thank you! -- jbl25 ------------------------------------------------------------------------ jbl25's Profile: http://www.excelforum.com/member.php...fo&userid=7225 View this thread: http://www.excelforum.com/showthread...hreadid=264883 |
All times are GMT +1. The time now is 12:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com