View Single Post
  #10   Report Post  
Posted to microsoft.public.access,microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Finding the biggest number out of 8 variables

Function Highest(Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8)

Hi. For this approach, here's a way to have an unspecified number of
inputs:

Function Highest(ParamArray v())
Highest = WorksheetFunction.Max(v)
End Function

Sub TestIt()
Dim x
x = Highest(12, 15, 9, 5)
MsgBox x
End Sub

= = =
Dana DeLouis


kc-mass wrote:
Try something like the following air code.

Sub Test()
Highest(Val1, Val2, Val3, Val4, Val5, Val6, Val7,Val8)
End Sub

Function Highest(Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8)
Highest = Var1
If Var2 Highest then Highest = Var2
If Var3 Highest then Highest = Var3
If Var4 Highest then Highest = Var4
If Var5 Highest then Highest = Var5
If Var6 Highest then Highest = Var6
If Var7 Highest then Highest = Var7
If Var8 Highest then Highest = Var8
End Function

Regards

Kevin

"Mojo" wrote in message
...
Hi All

Does anybody know of an easy way to find out which variable has the
highest
value out of 8 variables?

For example, I have these values in 8 vars:

3 0 7 30 37 17 0 7

Although from a human's perspective it's easy to see that the 5th var has
the highest value, how can I chose the appriopriate var programmatically?

Thanks