Excel中是否有合并函数? [英] Is there a coalesce-like function in Excel?

查看:162
本文介绍了Excel中是否有合并函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在同一行中的一组列(从左到右)中填充第一个非空条目,类似于SQL中的coalesce()。

I need to fill a cell with the first non-empty entry in a set of columns (from left to right) in the same row - similar to coalesce() in SQL.

在以下示例表中

---------------------------------------
|     |  A   |   B   |   C   |    D   |
---------------------------------------
|  1  |      |   x   |   y   |    z   |
---------------------------------------
|  2  |      |       |   y   |        |
---------------------------------------
|  3  |      |       |       |    z   |
---------------------------------------

我想在行A的每个单元格中放置一个单元格函数,以便我得到:

I want to put a cell function in each cell of row A such that I will get:

---------------------------------------
|     |  A   |   B   |   C   |    D   |
---------------------------------------
|  1  |  x   |   x   |   y   |    z   |
---------------------------------------
|  2  |  y   |       |   y   |        |
---------------------------------------
|  3  |  z   |       |       |    z   |
---------------------------------------

我知道我可以通过一系列IF功能来实现,但在我的实际工作表中,我有30列可供选择,如果有一个更简单的方法,我会很高兴

I know I could do this with a cascade of IF functions, but in my real sheet, I have 30 columns to select from, so I would be happy if there were a simpler way.

推荐答案

=INDEX(B2:D2,MATCH(FALSE,ISBLANK(B2:D2),FALSE))

这是一个数组公式。输入公式后,按下 CTRL + Shift + 输入以使Excel将其评估为数组公式。这将返回给定范围单元格的第一个非空值。例如,公式输入到标题为a的列中

This is an Array Formula. After entering the formula, press CTRL + Shift + Enter to have Excel evaluate it as an Array Formula. This returns the first nonblank value of the given range of cells. For your example, the formula is entered in the column with the header "a"

    A   B   C   D
1   x   x   y   z
2   y       y   
3   z           z

这篇关于Excel中是否有合并函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆