Temporary Storage in IF function

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

Guest

I have a function like this..
=IF(expr > 0 , expr , " ")

Now if my expr is again a big formula.. then is there any way of avoiding
repeating it as the second argument.. ie any temporary variable for storage
is available? like this...

=IF ((a=long_expr) > 0 , a , "");
 
If it is just one cell, then use a cell somewhere else to store the
value, eg put your expression in X1 then your formula can be:

=IF(X1>0,X1,"")

If you are doing this on a column of cells, then just copy the
expression down the X column (often referred to as a helper column),
then copy your formula down.

Hope this helps.

Pete
 
Unfortunately, you will have to have the formula stated twice, either within
the IF() function or somewhere else in the sheet.

However, if you are testing for an error, Excel 2007 has a new IfError()
function that allows you state your formula but once:

=iferror(long formula, value if formula errors)

If the formula works, IFERROR() gives the formula's results. If it errors,
IFERROR() returns the "value of formula errors"
 
You might also look at Laurent Longre's morefunc.xll add-in. The SETV and
GETV functions appear to be applicable to what you want to do.

http://xcell05.free.fr/

Or maybe you could just use
=MAX(expr, 0)
and use a custom number format like
0;-0;;
to suppress displaying the 0 if you do not want it displayed? The cell will
still have a value of 0 - so this may affect your dependent formulas.
 
You might try using 2 cells.

Say A1 is
=expr

And, in the result cell:
=IF(A1>0,A1,"")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top