进行比较时,如何避免在 Excel 中重复长公式? [英] How do I avoid repeating long formulas in Excel when working with comparisons?

查看:26
本文介绍了进行比较时,如何避免在 Excel 中重复长公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道类似以下内容

=IF(ISERROR(LONG_FORMULA), 0, LONG_FORMULA)

可以替换为

=IFERROR(LONG_FORMULA, 0)

但是我正在寻找一个表达式来避免在 REALLY_LONG_FORMULA 中输入两次

However I am looking for an expression to avoid having to type REALLY_LONG_FORMULA twice in

=IF(REALLY_LONG_FORMULA < threshold, 0, REALLY_LONG_FORMULA)

我该怎么做?

推荐答案

我想出了以下几点:

=IFERROR(EXP(LN(REALLY_LONG_FORMULA – threshold)) + threshold, 0)

它的工作原理是利用负数的对数产生错误以及 EXPLN 互为倒数.

It works by utilizing the fact that the log of a negative number produces an error and that EXP and LN are inverses of each other.

这样做的最大好处是,当您在 REALLY_LONG_FORMULA 的一个副本中更改某些内容时,它可以避免意外地将错误引入电子表格,而无需记住将相同的更改应用于 REALLY_LONG_FORMULA 的另一个副本 在你的 IF 语句中.

The biggest benefit of this is that it avoids accidentally introducing errors into your spreadsheet when you change something in one copy of REALLY_LONG_FORMULA without remembering to apply the same change to the other copy of REALLY_LONG_FORMULA in your IF statement.

大于中的比较

=IF(REALLY_LONG_FORMULA>=threshold,0,REALLY_LONG_FORMULA)

可以替换为

=IFERROR(threshold-EXP(LN(threshold-REALLY_LONG_FORMULA)),0)

以下示例(@Jeeped 提供):

Example below (provided by @Jeeped):

对于严格的不等式比较,请使用 @Tom Sharpe 指出的 SQRT(_)^2.

For strict inequality comparisons use SQRT(_)^2 as pointed out by @Tom Sharpe.

这篇关于进行比较时,如何避免在 Excel 中重复长公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆