[英]Formula to remove every middle name in a cell in Excel
Heello, I'm trying to remove every second and/or third name of every person in my excel file.你好,我正在尝试删除我的 excel 文件中每个人的第二个和/或第三个名字。 Now i'm doing it manually (and it' s very boring).
现在我手动做(这很无聊)。 Is there any formula to to it automatically?
有什么公式可以自动生成吗?
For example I have cell A1 that contains "Filippo Luigi Carlo", is possible to convert it to only "Filippo"?例如,我的单元格 A1 包含“Filippo Luigi Carlo”,是否可以将其转换为仅“Filippo”?
deleting every second and third(if the person has it) name in every cell of an excell file在 excel 文件的每个单元格中删除第二个和第三个(如果有人有的话)名字
You will want to use the following:您将需要使用以下内容:
=IFERROR(LEFT(A1,FIND(" ",A1)-1),A1)
What does it do?它有什么作用?
FIND(" ", A1)
FIND(" ", A1)
LEFT(A1, {step 1} - 1)
LEFT(A1, {step 1} - 1)
=IFERROR({step 2}, A1)
=IFERROR({step 2}, A1)
Limitations:限制:
Anne Marie Jones
will return Anne
instead of Anne Marie
)Anne Marie Jones
将返回Anne
而不是Anne Marie
)joining the party, I assume you want to keep the first name and the last name.加入聚会,我假设你想保留名字和姓氏。 The first name is given by @solar-Mike above.
名字由上面的@solar-Mike 给出。 For the last name, unfortunately excel only has formulae that search or find left to right, so more than two names are a problem.
对于姓氏,不幸的是 excel 只有从左到右搜索或查找的公式,所以两个以上的名字是个问题。 This site seems to give a good solution: a reverse find function
这个网站似乎给出了一个很好的解决方案:反向查找 function
The formula for the last name is horrendous: =IF( ISERROR( FIND(" ",A1) ),A1,RIGHT(A1, LEN(A1)-FIND("~", SUBSTITUTE(A1," ","~", LEN(A1)-LEN(SUBSTITUTE(A1," ","")) ) ) ) )姓氏的公式很可怕: =IF( ISERROR( FIND(" ",A1) ),A1,RIGHT(A1, LEN(A1)-FIND("~", SUBSTITUTE(A1," ","~" , LEN(A1)-LEN(替换(A1," ","")) ) ) )
Tack on the bit to get the first name, and you get:点击位以获取名字,您将获得:
=left(A1,find(" ",A1,1)-1) & " " & IF( ISERROR( FIND(" ",A1) ),A1,RIGHT(A1, LEN(A1)-FIND("~", SUBSTITUTE(A1," ","~", LEN(A1)-LEN(SUBSTITUTE(A1," ","")) ) ) ) ) =left(A1,find(" ",A1,1)-1) & " " & IF( ISERROR( FIND(" ",A1) ),A1,RIGHT(A1, LEN(A1)-FIND("~" , 替换(A1," ","~", LEN(A1)-LEN(替换(A1," ","")) ) ) )
That will drop all the middle names.这将删除所有中间名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.