[英]Get value of cell above last cell in column
I am looking for a formula that will get the value of the cell above the last cell in a column in Excel. 我正在寻找一个公式,该公式将获取Excel列中最后一个单元格上方的单元格的值。 I have the following formula that will get the value of the last cell in the column:
我有以下公式,该公式将获取列中最后一个单元格的值:
=LOOKUP(2, 1/('Historical Data'!A:A<>""),'Historical Data'!A:A)
But I am looking for the value of the cell that is right above it. 但我正在寻找位于其上方的单元格的价值。
For example, if I have a table that looks like: 例如,如果我有一个看起来像这样的表:
A B C A B C
2013 09 $40 2013年09月$ 40
2014 10 $78 2014年10月$ 78
2015 02 $60 2015 02 $ 60
I'm looking for column A to return "2014", not "2015" as it does now. 我正在寻找A列以返回“ 2014”,而不是现在的“ 2015”。
To return the second to last value I would use INDEX. 要返回倒数第二个值,我将使用INDEX。
=INDEX(A:A, COUNTA(A:A)-1, 1)
COUNTA to get the length of your array and -1 to step to the second to last value. COUNTA以获取数组的长度,而-1则步进到倒数第二个值。
Setup a meta row. 设置一个元行。
For example, in column "D", adjacent to each cell issue the following formula. 例如,在“ D”列中,与每个单元格相邻的位置发出以下公式。
=ROW()
Like so, 像这样
A B C D
2013 09 $40 1
2014 10 $78 2
2015 02 $60 3
At the end of the last row, issue a MAX command in the row column. 在最后一行的末尾,在行列中发出MAX命令。 In the aboe example, it will be D4.
在上述示例中,它将为D4。
=MAX(D1:D3)
D4 will have a value of 3 D4的值为3
This tells that your range has 3 rows. 这表明您的范围有3行。 You may then get your cell value by
然后,您可以通过
=INDIRECT("A" & D4-1)
Which will give you the value of A2. 这将为您提供A2的值。
You may hide row D after everything checks out. 一切检查完后,您可以隐藏D行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.