0

对于 Excel 公式,我需要包含数值的单元格列表中的第一个单元格:

 A  |  B  |  C  | ... |  Z  |
-----------------------------
    | 0.1 | 0.4 | ... | =0.1
    |     | 0.2 | ... | =0.2

我使用这个架构:

IF(ISNUMERIC(A1);A1;IF(ISNUMERIC(B1);A2;IF(ISNUMERIC(C1);C1;IF(...))))))))

不幸的是,这只适用于七列,因为 Excel 中的最大长度是有限的。

有没有办法重新表述这个公式,这样它就不会随着每一列的增加而变得更深?

4

4 回答 4

3

好吧,让我们来看看。尝试这个

=INDEX(A1:Y1,SUMPRODUCT((A1:Y1="")*1)+1)

sumproduct 计算空白的数量,然后索引查找单元格中的值,其中number of blanks + 1

希望有帮助。

于 2009-11-13T11:28:20.167 回答
2

In a single cell you can do this with an array formula:

Isnumber provides the test in Excel 2007

Multiply the result by column()

Use an if statement to help the following min function along:

Use the min function to identify the first numeric column.

Remember to use Ctrl-Shift-Enter when you want to make an array formula, not just enter.

=INDEX(A1:Z1,MIN(IF(ISNUMBER(A1:Z1),COLUMN(A1:Z1),5000)))

This also finds the first used column across multiple rows should you need that functionality.

于 2009-11-13T15:51:41.893 回答
1

也许这可能有助于XL:如何确定稀疏数组中使用的顶部/底部单元格

于 2009-11-13T11:32:58.897 回答
1

旁观者回答有效(假设第一个数字后面的单元格总是被填充)。

您还可以在 VBA 模块中编写自己的函数。

Public Function getFirstNumber(ByRef sourceRow As Range) As Double
    For Each Cell In sourceRow.Cells
        If WorksheetFunction.IsNumber(Cell) = True Then
            getFirstNumber = Cell.Value
            Exit Function
        End If
    Next Cell
End Function
于 2009-11-13T16:14:36.870 回答