Thread: Use of IIF
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Use of IIF

A question for my venerated colleagues in these newsgroups.

One of the threads that came up today led me to thinking about the IIF
function. For example, this simple test

If iCol 26 Then
col = Chr(iCol \ 26 + 64) & Chr(iCol Mod 26 + 64)
Else
col = Chr(iCol + 64)
End If

can also be written using IIF as

col = IIf(iCol 26, Chr(iCol \ 26 + 64) & Chr(iCol Mod 26 + 64),
Chr(iCol + 64))

My view is that whilst the second is shorter, and often a more obvious
statement (as in this case?) of what is happening, it can often be quite the
opposite, and be very confusing. As I tend to like to keep to a certain
style, for instance I always use If ... End If even for single statements, I
tend not to use it.

But is this wasteful prejudice? Do you guys use it? What are your views on
this topic? Where does it come from, is it likely to be supported evermore?
Do you care?

Look forward to hearing from you.

--

HTH

Bob Phillips