Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to find the maximum from a list of variables?

Kyrsten,

Try a function like the following:

Function MaxOfVariables(ParamArray V()) As Variant
Dim N As Long
Dim Max As Double
If IsMissing(V) = True Then
MaxOfVariables = CVErr(xlErrValue)
Exit Function
End If
For N = LBound(V) To UBound(V)
If IsNumeric(V(N)) Then
If CDbl(V(N)) Max Then
Max = CDbl(V(N))
End If
Else
MaxOfVariables = CVErr(xlErrNum)
Exit Function
End If
Next N
MaxOfVariables = Max
End Function

If no variables as passed to it, it will cause a #VALUE error. If any
variable is not numeric, it returns a #NUM! error. If everything is numeric,
it will return the maximum of the values passed in.

Dim MyMax As Double
MyMax = MaxOfVariables(a,b,c,d)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"KyWilde" wrote in message
...
I have a list of four varables: a, b, c, d all have integer values...

I would like to figure out the maximum amount from the four. How can I do
this? Is there a max(a,b,c,d) function I can use? Or do I need to write
one?

Thanks,
-Kyrsten Wilde



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
MAXIMUM # OF X VARIABLES USED FOR MULTIVARIATE REGRESSION? WA Excel Worksheet Functions 4 January 16th 09 02:33 AM
How do I calculate maximum with variables. DanASU Excel Worksheet Functions 3 June 13th 08 08:01 PM
find maximum and minum variables for multiple names [email protected] Excel Worksheet Functions 1 November 29th 07 10:21 PM
How do I find the maximum time value from a list Lee Excel Worksheet Functions 3 June 20th 06 10:48 AM
maximum variables within sub mike allen[_2_] Excel Programming 3 January 26th 05 10:16 PM


All times are GMT +1. The time now is 04:53 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"