1

如何提取多个不同单元格的第一个单词,并让每个第一个单词一起显示在另一个以逗号分隔的单元格中?

例如 A1 显示“Firstname1 Lastname1”,A2 显示“Firstname2 Lastname2”,A3 显示“Firstname3 Lastname3”,

我需要一个公式,允许我在单元格 D2“Firstname1,Firstname2,Firstname3”中显示以下内容

我找到了这个解决方案,它给了我一个单元格的第一个单词并在另一个单元格中显示它,但我不知道如何获取多个单元格的第一个单词并将它们全部显示在另一个单元格中以逗号分隔

=LEFT(A1,SEARCH(" ",A1)-1)

Excel函数从其他单元格中的句子中获取第一个单词

谢谢!

4

3 回答 3

1

What if instead of just three cells you have an Excel range A1:A100 which has all the names? How would you concatenate in such an instance? Will you type that long a formula?

As Jerry suggested, VBA is Apt for this. But what if you do not want to use VBA or long formulas?

See this example. I am taking 10 cells for the sake of explaining.

Let's say the data looks like this.

enter image description here

Now select the entire column and click on Data~~>Text To Columns

enter image description here

When you click finish, the output will be like this

enter image description here

Now in cell say E4, type this =Transpose(A1:A10). Replace A1:A10 with the actual range. However do not press the Enter key. Press the key F9. You will see that all the first names are now visible.

enter image description here

Simply copy that and press Esc. Now open Notepad and paste it there.

Next delete the { and the }

Next manually replace "," by , and you will get what you wanted.

enter image description here

于 2013-09-16T09:39:10.703 回答
0

=LEFT(A1,SEARCH(" ",A1)-1) &", "&LEFT(A2,SEARCH(" ",A2)-1)&", "&LEFT(A3,SEARCH(" ",A3)-1 )

于 2013-09-16T08:29:52.537 回答
0

使用您当前的公式,=LEFT(A1,SEARCH(" ",A1)-1)您可以将后续单元格的值添加到先前的计算中,并构建逗号分隔的值。

B1中,我们有您的原始公式,=LEFT(A1,SEARCH(" ",A1)-1)
B2中,我们连接先前的结果,并添加逗号和新单词:

=B1 & "," & LEFT(A2,SEARCH(" ",A2)-1)

将其复制到 B3(及以上),您将慢慢看到完整列表已创建。

最后一个值是你想要的,所以,在 C1 中,把公式

=OFFSET(B1,COUNTA(B:B)-1,0)

(并隐藏 B 列,使其看起来更好)

于 2013-09-16T17:53:55.097 回答