简体   繁体   English

在Excel中使用另一个变量更改公式范围

[英]Changing Formula Range with Another Variable in Excel

I'm trying to adjust how much of a data my formula looks at depending on another variable. 我试图根据另一个变量来调整公式中要查看的数据量。

An example would be having 20 years worth of returns =IRR(A2:A22) 例如,有20年的收益=IRR(A2:A22)

I'd like to add a variable that you change depending on how many years you would want to look at. 我想添加一个变量,您可以根据要查看的年份来更改该变量。 Lets say we only wanted to look at the first 10 years how would I get my formula to automatically find the data for =IRR(A2:A12) ? 可以说,我们只想看看前10年,我如何才能得到公式自动查找=IRR(A2:A12)

Let's assume that the year "variable" is in cell A1. 假设年份“变量”在单元格A1中。 It could be any cell, but for this example, A1: 它可以是任何单元格,但对于此示例,为A1:

=IRR($A$2:INDEX($A:$A,$A$1+2))

Notice that $A$1 is in the formula. 请注意,$ A $ 1在公式中。 You change that to your year variable. 您将其更改为年份变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM