selecting in three values

mcgrcoAgain

Registered User.
Local time
Today, 13:41
Joined
Jan 26, 2006
Messages
47
Does anyone know how to do this.

I need to pass three numbers to a function in VBA.

eg 4,4,6

The function should look at the lowest two numbers and and return the highest. if the lowest two are the same it should return that value.

2,3,6 would return 3

4,4,6 would return 4

Any help is a appreciated
 
Something like this?

function mid_val (a as long, b as long, c as long) as long

if a = b then
if a > c then
mid_val = c
else
mid_val = a
end if
exit function
end if

if b = c then
if a > b then
mid_val = b
else
mid_val = a
end if
exit function
end if


if a>b then
if b>c then
mid_val = b
else
if a>c then
mid_val = c
else
mid_val = a
end_if
end if
else
if a>c then
mid_val = a
else
if b>c then
mid_val = c
else
mid_val = b
end if
end if

end function
 
why not use a bubble sort and return the second element
 
many thanks for the help chergh.

where would I find details on what a bubble sort is?

thanks again
 

Users who are viewing this thread

Back
Top Bottom