Max from columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 4 columns with numbers. I want to make a 5th column that will compare
the 4 columns and store the max number . IE. if a row has the following
number - 1, 17, 24, 5. I want the 5th column to show "24." How can I do
that?
 
With a NESTED IIF Statements or with a custom VBA function. The Nested IIF
would look something like the following AND each of the fields MUST have a value.

IIF(A>=B And A>=C and A>=D,A,IIF(B>=C and B>=D,B,IIF(C>=D,C,D)))

Using a custom VBA function would allow you to handle nulls in any of the fields
and would also allow you to have more or less than 4 fields.

You could rewrite the above to use the NZ function around each of the values, to
force a value for null fields.

Post back if you need a VBA function and cannot find one by using Google to
search the Access Groups.
 
I created a Max() function once. Pass it all the values to be compared, and
send back the highest. No idea where that code is, but it's only about 5
lines.
 
Back
Top