Farstride
Farstride

Reputation: 145

Microsoft Excel Putting a Function in an IF function

I'm writing an IF function, and one of the [If_value_False] slots needs to be a random Function.

It works fine, but once the random formula is posted, the cell dosn't randomize, the IF function behaves as if whatever is in the value true has to be text, not a forumla.

Here's the function I've got:

=IF(ISBLANK(A2),"","=rand()")

If A2 is blank, this function should leave everything blank too whenever it's placed If A2 is not blank, it should add a random function. That works up to there. The cell dosn't follow the =RAND() function.

How can I fix this?

Upvotes: 2

Views: 433

Answers (2)

brettdj
brettdj

Reputation: 55672

Remove the quotes around the RAND() function

=IF(ISBLANK(A2),"",RAND())

Upvotes: 3

telcopro
telcopro

Reputation: 148

I think your formula works as expected - it sets the displayed contents of the cell to the text "=rand()". If you want to set it to an actual function, I believe you have to do it from VBA using the notation

ActiveCell.Formula = "=rand()".

Upvotes: -1

Related Questions