Is the number of arguments in a function limited?

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

Guest

I am using an IIf function containing nested arguments and seem to run into a
problem when the number of arguments in the nest exceeds 5. Is there a limit
to the number of arguments than can be nested within an IIf function?
 
I don't know if there is a limit to the number of nested IIfs; however,
unless you are using nested IIfs for a query or writing SQL, then I would
suggest you use either If...Then..Else or Select Case instead. Nested IIfs
are hard to read. Also, note that both sides (True side, and False side) are
both evaluated before the function makes a selection. This makes it easy to
create an error or get unexpected results.
 
If I recall correctly you can't next IIF functions more than 7 deep. I know
there is a limit, but I'm not sure if I got the number correct.

Have you considered using the SWITCH function or writing a custom function
in VBA to handle this? I find nested IIF (beyond 2) difficult to edit so I
tend to avoid them.
 
Back
Top