Home > Software design >  Returning the compared input as-is if the IF function is true or false
Returning the compared input as-is if the IF function is true or false

Time:11-15

Is there a pre-built-in function to run a check on a function and change or just reuse that input depending on if it's true or false? So for example currently to do what I want to do, I have #long_formula, and I want to suppress that output if it's negative. My if statement would look like IF(#long_Formula>=0,#long_formula,""). Is there a more compact and cleaner way to perform this comparison? I'm trying to avoid spreading the calculation over multiple cells, and I don't always want to return an empty cell as the false condition. I can make my own function, but it always seems to not play nice with arrays when I do so (because my VBA knowledge is very limited).

CodePudding user response:

If you're using Excel 365 you can use the LET() function:

=LET(f,long_formula,IF(f>=0,f,""))
  • Related