[英]How do I make an excel formula skip empty cells
I have a spreadsheet with data in a single row. 我有一个包含一行数据的电子表格。 The data is arranged by year with the earliest date in the right most cell and the latest date in the far left cell.
数据按年份排列,最早的日期在最右边的单元格中,最新的日期在最左边的单元格中。
What I need is a formula that will begin looking at the cells beginning on the right (earlier date) and move to the left toward a later date skipping the empty cells. 我需要的是一个公式,该公式将开始查看从右侧(较早的日期)开始的单元格,并向左移至较晚的日期,跳过空单元格。 As soon as it finds data in one of the cells I need it to stop and show the value in that cell.
一旦它在其中一个单元格中找到数据,我就需要它停止并显示该单元格中的值。
I have attached a picture as an example, in that picture I need it to begin at the cell for 2003 and begin moving left ignoring empty cells until it finds a cell with data. 我以图片为例,在该图片中,我需要它从2003年的单元格开始,并开始向左移动,忽略空白单元格,直到找到包含数据的单元格。 In this case the cell for 2005 contains data.
在这种情况下,2005年单元格包含数据。 I need it to copy that value ($2.43) and place it in the cell marked earliest value.
我需要它来复制该值($ 2.43)并将其放在标记为最早值的单元格中。
In the pictue I manually entered 2.43 in the cell for 2005 to show what i need.! 在图片中,我在2005年的单元格中手动输入了2.43,以显示我的需求。
You can use LOOKUP
function to get the last value in a row, so if you have years in A1:J1
and dollar amounts in A2:J2
just use this formula to get the last numeric value from A2:J2
您可以使用
LOOKUP
函数获取行中的最后一个值,因此,如果您在A1:J1
有年份,而在A2:J2
美元金额,只需使用此公式从A2:J2
获取最后一个数值
=LOOKUP(9.99E+307,A2:J2)
9.99E+307 is [almost] the largest value that Excel allows, when you use that "big num" as lookup value the result is the last number in the range 9.99E + 307 [几乎]是Excel允许的最大值,当您使用“大数”作为查找值时,结果是该范围内的最后一个数字
I made two ranges, starting E4 to J4, I place 1,2,3,4,5,6. 我做了两个范围,从E4到J4,我放置了1,2,3,4,5,6。 Below (thus range: E5-J5) I placed 6,5,4,3,2,1.
在下面(因此范围:E5-J5),我放置了6,5,4,3,2,1。
In a random cell I placed this formula: 在一个随机单元格中,我放置了以下公式:
=INDEX(E5:J5,MATCH(MIN(E4:J4),E4:J4,0))
This look in E4:J4 for the number that matched MIN(E4:J4), thus the lowest number. 在E4:J4中查找与MIN(E4:J4)匹配的数字,即最低的数字。 Then selects that value, matching the index, in the range E5:J5.
然后在范围E5:J5中选择与索引匹配的值。
As follows from your image - year should be less than 10 yr history . 如下所示,您的年份应该少于10年的历史 。 In that case try following formula (I suppose that your data ( years and values) are in
B3:X4
range): 在这种情况下,请尝试使用以下公式(我想您的数据(年和值)在
B3:X4
范围内):
=HLOOKUP(MIN(IF((B4:X4<>"")*(B3:X3>YEAR(NOW())-10),B3:X3)),B3:X4,2,0)
Note, that it is an array formula, so you need to press CTRL + SHIFT + ENTER to evaluate it. 请注意,这是一个数组公式,因此您需要按CTRL + SHIFT + ENTER对其求值。
If you don't need to use condition year should be less than 10 yr history , just remove *(B3:X3>YEAR(NOW())-10)
from the formula: 如果您不需要使用条件年份应少于10年的历史记录 ,只需从公式中删除
*(B3:X3>YEAR(NOW())-10)
:
=HLOOKUP(MIN(IF(B4:X4<>"",B3:X3)),B3:X4,2,0)
and press CTRL + SHIFT + ENTER to evaluate it. 然后按CTRL + SHIFT + ENTER进行评估。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.