LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Find variable with the highest value

Option Explicit
Dim maxint As String
Dim maxval As Long
Sub CheckMax()
Dim int1 As Long
Dim int2 As Long
Dim int3 As Long
Dim int4 As Long
Dim int5 As Long

int1 = Rnd() * 100
int2 = Rnd() * 100
int3 = Rnd() * 100
int4 = Rnd() * 100
int5 = Rnd() * 100

getmax 1, int1
getmax 2, int2
getmax 3, int2
getmax 4, int4
getmax 5, int5

MsgBox "Integer " & maxint & " hax max value of " & maxval

End Sub
Sub getmax(ByRef text As String, ByRef intval As Long)
If intval maxval Then
maxval = intval
maxint = text
End If




End Sub


"MJKelly" wrote in message
...
Hi, I have 5 variables containing integers. How can I use vba to
identify the variable with the highest value?

Thanks
Matt


 
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
How do I find the second highest value. Peter Excel Discussion (Misc queries) 4 May 19th 10 03:52 PM
how do I find 2nd highest MAX in a row cruise director Excel Discussion (Misc queries) 4 August 20th 08 12:16 AM
need to find highest total [email protected] Excel Programming 1 October 24th 06 01:26 PM
Find the highest value on the column frukyy Excel Discussion (Misc queries) 5 October 4th 06 02:28 PM
Displaying the Highest Value in a user-variable range of cells Tabby Excel Programming 1 April 26th 05 09:12 PM


All times are GMT +1. The time now is 01:09 AM.

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"