string 如何将字符串从“lastName, firstName”切换为“firstName LastName”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13331358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 01:42:15  来源:igfitidea点击:

How can I switch a string from "lastName, firstName" to "firstName LastName"?

stringexcelformatting

提问by pencilCake

I have a column full of names written as:

我有一列写满名字的列:

"lastName, firstName"

“姓,名”

I want to have a nother column that has this name list written as:

我想要另一列将这个名字列表写成:

"firstName LastName"

“名字姓氏”

So, how can I switch a string from "lastName, firstName" to "firstName LastName" ?

那么,如何将字符串从 "lastName, firstName" 切换为 "firstName LastName" ?

回答by barry houdini

If the first name is in A2 try this formula in B2 copied down

如果名字在 A2 中,请尝试将 B2 中的这个公式复制下来

=MID(A2&" "&A2,FIND(" ",A2)+1,LEN(A2)-1)

=MID(A2&" "&A2,FIND(" ",A2)+1,LEN(A2)-1)

回答by Conroy Daley

Enter data into cells e.g.

在单元格中输入数据,例如

Brown, John
Green, Bob
Smith, Will

(Note that the comma in this case is the delimiter which the system will use to separate the entries) Highlight these cells.
Click on the "Data" tab, click on "Text to Column".
Choose options offered.

(请注意,在这种情况下,逗号是系统用来分隔条目的分隔符)突出显示这些单元格。
单击“数据”选项卡,单击“文本到列”。
选择提供的选项。

回答by Excel Dude

The worked for me =RIGHT(C3,LEN(C3)-LEN(LEFT(C3,FIND(",",C3)-1))-1) & " " & LEFT(C3,FIND(",",C3)-1)

对我有用 =RIGHT(C3,LEN(C3)-LEN(LEFT(C3,FIND(",",C3)-1))-1) & " " & LEFT(C3,FIND(",",C3 )-1)

回答by Jay Wind

The above answeris incorrect. In fact, for my own name, Jay Jacob Wind, the formula breaks. The correct formula is:

上面的答案是不正确。事实上,对于我自己的名字 Jay Jacob Wind 来说,这个公式被打破了。正确的公式是:

Assuming Last, First is in column A, separated by one comma and a space bar

假设 Last, First 在 A 列中,由逗号和空格分隔

For first name:

对于名字:

=mid(A2,find(",",A2)+2,99)

For last name:

对于姓氏:

=mid(A2,1,find(",",A2)-1)

Put together, assuming Column B is First Name and Column C is Last Name =B2&" "&C2

放在一起,假设列 B 是名字,列 C 是姓氏 =B2&" "&C2

or simply (but more complexly)

或者简单地(但更复杂)

=mid(A2,find(",",A2)+2,99)&" "&mid(A2,1,find(",",A2)-1)

but I like separating them into two columns, then concatenating them

但我喜欢将它们分成两列,然后将它们连接起来