查找范围中的第一个非空白单元格 [英] Find first non-blank cell in a range
问题描述
我正在处理一列数据,其中一行或多个单元格可以为空。
I am working with a list of data where one or multiple cells in a row can be blank.
表示列表是单元格 A1
, A2
, A3
, A4
。我正在尝试创建一个将执行以下操作的函数:
Lets say the list is cells A1
, A2
, A3
, A4
. I am trying to create a function that will do the following:
IF A1 has a value I want the cell to return A1.
IF A1 is empty then I want it to return A2.
IF A1 and A2 are both empty I want it to return A3.
If A1, A2 and A3 are all empty I want it to return A4.
推荐答案
first result on google: http://chandoo.org/wp/2014/01/15/find-first-non-blank-item-in-a-list-excel-formulas/
此公式返回范围
B1:B100
的第一个TEXT单元格:
This formula returns the first TEXT cell for a range
B1:B100
:
= VLOOKUP(*,B1:B100,1,FALSE)
*是Excel中的通配符。当您要求VLOOKUP找到*时,它会找到包含任何内容的第一个单元格。
* is a wild card in Excel. When you ask VLOOKUP to find *, it finds the first cell that contains anything.
注意:此方法查找包含任何TEXT的第一个单元格。因此,如果第一个非空白单元格是数字(或日期,%或布尔值),则该公式显示包含文本的下一个单元格。
NOTE: This approach finds first cell that contains any TEXT. So if the first non-blank cell is a number (or date, % or Boolean value), the formula shows next cell that contains text.
如果您需要找到非空白,该网址提供以下解决方案:
If you need to find non-blank that url gives the following solution:
如果你想找到第一个非空值,无论是文本还是数字,那么可以使用下面的数组公式。
If you want to find first non-blank value, whether it is text or number, then you can use below array formula.
= INDEX(B3:B100 ,MATCH(FALSE,ISBLANK(B1:B100),0))
确保按 CTRL Shift + 输入此公式后输入。
该公式如何工作?
-
ISBLANK(B1:B100)
部分:这给了我们TRUE的列表
/FALSE
取决于B1:B100
中的98个单元格是否为空。看起来像这样:
{TRUE; TRUE; TRUE; FALSE; FALSE; FALSE; FALSE; ...}
ISBLANK(B1:B100)
portion: This gives us list ofTRUE
/FALSE
values depending on the 98 cells inB1:B100
are blank or not. It looks like this:{TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE; ...}
MATCH(FALSE,ISBLANK(...),0)
部分:一旦我们有 TRUE
/ FALSE
值,我们只需要找到第一个 FALSE
值(即,第一个非空白单元格)。这就是这个 MATCH
功能。
MATCH(FALSE, ISBLANK(…), 0)
portion: Once we have the TRUE
/ FALSE
values, we just need to find the first FALSE
value (ie, first non-blank cell). That is what this MATCH
function does. It finds an exact match of FALSE value in the list.
INDEX(B1:B100,MATCH(...))
部分:一旦我们知道哪个单元格是第一个非空白单元格,我们需要它的值。那就是 INDEX
。
INDEX(B1:B100, MATCH(…))
portion: Once we know which cell is the first non-blank cell, we need its value. That is what INDEX
does.
这篇关于查找范围中的第一个非空白单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!