Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Contour Chart - Find Vals for Shaded Areas PCSBryan Charts and Charting in Excel 0 October 5th 09 06:55 PM
Excel Conditional Formatting (Compare Vals in 2 Columns) [email protected] Excel Worksheet Functions 3 April 21st 09 04:25 AM
Why do I get #NUM! for a GEOMEAN calc on a set of positive vals Nick Curties Excel Worksheet Functions 14 June 25th 07 01:42 PM
How do I write a VLOOKUP function that returns 0's, not neg vals? dbsavoy Excel Worksheet Functions 4 August 24th 06 05:26 PM
How get rid of these errors if cell has no vals? Jay Excel Worksheet Functions 3 March 4th 05 08:07 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"