Excel公式中有变量吗? [英] Are there such things as variables within an Excel formula?

查看:674
本文介绍了Excel公式中有变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我讨厌重复功能,特别是在Excel公式中。有什么办法可以避免这样的情况:



= IF(VLOOKUP(A1,B:B,1,0)> 10,VLOOKUP(A1,B: B,1,0) - 10,VLOOKUP(A1,B:B,1,0))



[上面只是一个简单的例子,不是我正在使用的特定公式。]

解决方案

您可以为公式的VLOOKUP部分定义一个名称。


  1. 突出显示包含此公式的单元格

  2. 在插入菜单上,转到名称,然后单击定义

  3. 输入变量的名称(例如值)

  4. 在引用框中,输入您的VLOOKUP公式: = VLOOKUP(A1,B:B,1,0)

  5. 点击添加,然后关闭对话框

  6. 在您的原始公式中,使用您刚才定义的名称替换VLOOKUP部件: = IF(Value> 10,Value - 10,Value)

步骤(1)在这里很重要:我想在第二行,你希望Excel使用 VLOOKUP(A2,B:B,1,0),第三行 VLOOKUP(A3,B:B,1,0)等等。步骤(4)通过使用相对引用( A1 B:B )实现此目的,而不是绝对参考( $ A $ 1 $ B:$ B )。


I hate repeating functions, particularly in Excel formulas. Is there any way that I can avoid something like:

=IF( VLOOKUP(A1, B:B, 1, 0) > 10, VLOOKUP(A1, B:B, 1, 0) - 10, VLOOKUP(A1, B:B, 1, 0) )

[The above is just a simple example of the problem, and not a particular formula that I'm working with.]

解决方案

You could define a name for the VLOOKUP part of the formula.

  1. Highlight the cell that contains this formula
  2. On the Insert menu, go Name, and click Define
  3. Enter a name for your variable (e.g. 'Value')
  4. In the Refers To box, enter your VLOOKUP formula: =VLOOKUP(A1,B:B, 1, 0)
  5. Click Add, and close the dialog
  6. In your original formula, replace the VLOOKUP parts with the name you just defined: =IF( Value > 10, Value - 10, Value )

Step (1) is important here: I guess on the second row, you want Excel to use VLOOKUP(A2,B:B, 1, 0), the third row VLOOKUP(A3,B:B, 1, 0), etc. Step (4) achieves this by using relative references (A1 and B:B), not absolute references ($A$1 and $B:$B).

这篇关于Excel公式中有变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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