Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Contour Chart - Find Vals for Shaded Areas | Charts and Charting in Excel | |||
Excel Conditional Formatting (Compare Vals in 2 Columns) | Excel Worksheet Functions | |||
Why do I get #NUM! for a GEOMEAN calc on a set of positive vals | Excel Worksheet Functions | |||
How do I write a VLOOKUP function that returns 0's, not neg vals? | Excel Worksheet Functions | |||
How get rid of these errors if cell has no vals? | Excel Worksheet Functions |