如何以可读的方式重写excel公式? [英] How to rewrite excel formulas in a readable manner?

查看:24
本文介绍了如何以可读的方式重写excel公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以这种方式包含公式的 Excel 文件:

I have an Excel file with formulas in this manner:

=IF(OR(ISERROR(G16),ISERROR(G17)),X16,IF(OR(G16="xxx",G16="yyy",G16="zzz"),Y16,IF(G16="333","NA",IF(G17="333",Z16,IF(D17="",IF((HEX2DEC(W$10)-HEX2DEC(W16))/VLOOKUP(F16,$M$36:$N$41,2,FALSE)<0,0,(HEX2DEC(W$10)-HEX2DEC(W16))/VLOOKUP(F16,$M$36:$N$41,2,FALSE)), IF((HEX2DEC(W17)-HEX2DEC(W16))/VLOOKUP(F16,$M$36:$N$41,2,FALSE)<0,0,(HEX2DEC(W17)-HEX2DEC(W16))/VLOOKUP(F16,$M$36:$N$41,2,FALSE)))))))

我想简化它们,以便以更易读的方式编写.

I would like to simplify them so it will be written in a more readable manner.

  • 我可以以缩进的方式编辑/编写 Excel 公式吗?
  • 我可以做哪些简化?
  • 我应该使用 VBA 脚本而不是 Excel 的公式吗?

推荐答案

作为使用辅助列的示例,您可以使用以下内容缩短公式

As an example using helper columns, you could shorten the formula with the following

[A1] =VLOOKUP(F16,$M$36:$N$41,2,FALSE)

[B1] =HEX2DEC(W$10)

[C1] =HEX2DEC(W16)

[D1] =HEX2DEC(W17)

然后将大公式缩短为

=IF(OR(ISERROR(G16),ISERROR(G17)),X16,IF(OR(G16="xxx",G16="yyy",G16="zzz"),Y16,IF(G16="333","NA",IF(G17="333",Z16,IF(D17="",IF((B1-C1)/A1<0,0,(B1-C1)/A1), IF((D1-C1)/A1<0,0,(D1-C1)/A1))))))

这在使用 DATE 或 NOW 等易失性函数时特别有效,因为您不想在结果相同时为每个单元格重新计算.

This is particularly effective when using volatile functions such as DATE or NOW which you don't want to recalc for every cell when it's the same result.

它是否更具可读性,也许不是,但您可以用适当的注释标记列标题

Whether it's more readable, perhaps not but you can label column headings with appropriate comments

这篇关于如何以可读的方式重写excel公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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