Thread: IIf VBA Problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default IIf VBA Problem

On Mon, 26 Mar 2007 12:10:38 +0200, "Paweł Zalewski"
wrote:

Hi,

Ok so I know why its allways False :)

but.. still have problem with IIf

i can write
IIf(Replace(Sheet1.Cells(2,5),"X", "B"), "="& FJan, 0)
but than i get an error: Type mismatch.


Your syntax seems completely screwed up, and I don't see you doing anything
with the result. Perhaps you are trying to use the syntax for the Excel IF
worksheet function, which is a different function.

Look at HELP and the Example for the IIF function in VBA HELP.

Returns one of two parts, depending on the evaluation of an expression.

Syntax

IIf(expr, truepart, falsepart)

In your statement:

expr = Replace(Sheet1.Cells(2,5),"X", "B")

I don't see how that expr will evaluate to True or False

truepart = "="& FJan

Is FJan defined someplace in your VBA routine? Or are you not using Option
Explicit?

Finally, since the IIF function returns something, you need to store that
return value in something. I don't see that being done.
--ron