跳到主要内容

如何从Excel的单元格中删除特定字符之前或之后的文本?

本文介绍了从Excel单元格中删除特定字符或第n个出现字符之前或之后的文本的不同方法。


通过在Excel中查找和替换来删除特定字符之前或之后的文本

要使用“查找和替换”功能删除特定字符之前或之后的所有文本,请执行以下操作。

1.选择要删除特定字符之前或之后的文本的单元格,按 按Ctrl + H 键打开 查找和替换 对话。

在“查找和替换”对话框中:

1.要删除逗号之前的所有特定字符,请键入 *, 查找内容 文本框;

2.要删除逗号等特定字符后的所有字符,请键入 ,*查找内容 文本框;

笔记:

1.您可以根据需要将逗号更改为任何字符。

2.在这种情况下,最后一个逗号之前或之后的所有文本将从选定的单元格中删除。

2。 保持 更换 文本框为空,然后单击 “全部替换” 按钮。 看截图:


轻松删除Excel中单元格中的所有数字,非数字或指定字符

Kutools用于 Excel's 移除角色 实用程序可帮助您轻松删除Excel中选定单元格中的所有数字,非数字或指定字符。
立即下载 Kutools for Excel 的全功能 30 天免费试用版!


通过公式删除第一个/最后一个特定字符之前或之后的文本

本部分将向您显示删除Excel单元格中第一个/最后一个特定字符之前或之后的所有内容的公式。

删除第一个逗号之前的所有内容, 请:

选择一个空白单元格,将以下公式复制并粘贴到其中,然后按 输入 键。 然后拖动 填充手柄 将公式应用于其他单元格。 看截图:

分子式: 在第一个逗号之前删除所有内容

=右(B5,LEN(B5)-找(”,",B5))

笔记:

1.在上面的公式中,B5是您要从中删除文本的单元格,而“,”是您要从中删除文本的字符。

2.要删除最后一个特定字符之前的所有字符,请使用以下公式:

=右(B5,LEN(B5)-FIND(“ @”,SUBSTITUTE(B5,"字符“,” @“,(LEN(B5)-LEN(替换(B5,"字符“,”“))))/ LEN(”字符“))))

删除第一个逗号后的所有内容, 请:

选择一个空白单元格,将以下公式复制并粘贴到其中,然后按 输入 键。 然后拖动 填充手柄 将公式应用于其他单元格。 看截图:

分子式: 删除第一个逗号后的所有内容

= LEFT(B5,FIND(“,”,B5)-1)

笔记:

1.在上面的公式中,B5是您要从中删除文本的单元格,而“,”是您要从中删除文本的字符。

2.要删除最后一个特定字符之后的所有字符,请使用以下公式:

=左(B5,FIND(“ @”,SUBSTITUTE(B5,"字符“,” @“,LEN(B5)-LEN(替换(B5,"字符“,”“)))))-1)


通过公式删除第n个出现字符之前或之后的文本

下面的公式可以帮助删除Excel单元格中第n个出现字符之前或之后的所有字符。

从单元格中删除第n个出现字符之前的所有字符, 你需要:

选择一个空白单元格以输出结果,将以下公式复制到其中,然后按 输入 键。 然后拖动 填充手柄 将公式应用于其他单元格。 看截图:

分子式: 在第二次出现逗号之前删除所有内容

=右(替代(B5,“,CHAR(9), 2),LEN(B5)-FIND(CHAR(9),SUBSTITUTE(B5,“,CHAR(9), 2),1)+ 1)

笔记:

1.在公式中 B5,“而 2 数字表示第二次出现逗号后的所有内容将从单元格B5中删除。

2.您可以更改“,“而 2 根据需要将其编号为任何字符和出现位置编号。

从单元格中删除第n个出现字符之后的所有字符, 你需要:

选择一个空白单元格以输出结果,将以下公式复制到其中,然后按 输入 键。 然后拖动 填充手柄 将公式应用于其他单元格。 看截图:


分子式: 在第二次出现逗号后删除所有内容

=左(替换(B5,",“,CHAR(9),2),FIND(CHAR(9),SUBSTITUTE(B5,",“,CHAR(9),2),1)-1)

笔记:

1.在公式中 B5,“而 2 数字表示第二次出现逗号后的所有内容将从单元格A7中删除。

2.您可以更改“,“而 2 根据需要将其编号为任何字符和出现位置编号。


使用 Kutools for Excel 轻松删除特定字符之前/之后的文本

如果一个范围中的每个单元格只有一个逗号分隔符,并且您想从单元格中删除该逗号之前或之后的所有内容,请尝试 分裂细胞 实用程序 Kutools for Excel。 此实用程序将帮助您单击几下即可解决问题:

1.选择要删除逗号之前或之后的所有内容的单元格,然后单击“确定”。 库工具 > 文本 > 分裂细胞。 看截图:

2.在 分裂细胞 对话框中,选择 拆分为列 在选项 Type 部分,并在 分割为 部分,选择 其他名称 选项,并在空白框中键入逗号,然后单击 OK 按钮。 看截图:

3.另一个 分裂细胞 弹出对话框,选择一个空白单元格来查找文本,然后单击 OK 按钮。

然后,您可以看到所选单元格被特定字符-逗号分隔。 看截图:

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


Kutools for Excel- 帮助您始终提前完成工作,有更多时间享受生活
您是否经常发现自己正在赶上工作,缺乏时间为自己和家人度过?  Kutools for Excel 可以帮你处理 80% Excel 拼图,提高 80% 的工作效率,让您有更多时间照顾家人,享受生活。
适用于300种工作场景的1500种高级工具使您的工作比以往更加轻松。
从现在起,不再需要记住公式和VBA代码,让您的大脑休息一下。
复杂和重复的操作可以在几秒钟内一次性完成。
每天减少成千上万的键盘和鼠标操作,现在告别职业病。
在3分钟内成为Excel专家,帮助您快速获得认可并提薪。
110,000名高效人才和300多家世界知名公司的选择。
使您的$ 39.0的价值超过$ 4000.0的他人培训。
全功能免费试用 30 天。 60 天无理由退款保证。

Comments (60)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
السلام عليكم كيفكم اسمي احمد ابراهيم محمد علامي من ذوي الاعاقة اصم وابكم الثانوية وحاسوب من الرياض جازان صبيا رقم جوالي قديم اشويه 0501601641 ابغي مساعدة فايدة وشكرا لكم جميعا أن شاءالله
This comment was minimized by the moderator on the site
رقمي 0501601641 وشكرا لكم جميعا أن شاءالله السلام عليكم كيفكم اسمي احمد ابراهيم محمد علامي
This comment was minimized by the moderator on the site
Hi how can i split or add spacing in between each textRoominCoolDecoApartmentinBrunswickEast
This comment was minimized by the moderator on the site
Hi z,If every word in the sentence starts with a capital letter, you can try one of the methods below to get it done:1. To add space between each word, methods in this article can do you a favor:How To Insert Spaces Before Capital Letters In Excel?
https://www.extendoffice.com/documents/excel/1864-excel-insert-space-before-capital-letter.html

2. To split text by capital letter in the sentence, you can try the methods in this article.How To Split Text Into Separate Columns By Capital Letter In Excel?
https://www.extendoffice.com/documents/excel/3336-excel-split-text-by-capital-letter.html
This comment was minimized by the moderator on the site
Hi I have the next text:

/credit-loan/super-credit/- from 1251 to 1016( -18.78%)
/credit-loan/no-credit/- from 1018 to 703( -30.94%)
/loan-loan-credit-cards- from 773 to 633( -18.11%)
/loan-loan/fair-loan/- from 321 to 502( -29.69%)

I need to delete everything after "-" before the from, including the character "-" so the above to become:

/credit-loan/super-credit/
/credit-loan/no-credit/
/loan-loan-credit-cards
/loan-loan/fair-loan/

And after I would also need to have the above without the "/" as in (but I think I can manage that later):

/credit-loan/super-credit
/credit-loan/no-credit
/loan-loan-credit-cards
/loan-loan/fair-loan
This comment was minimized by the moderator on the site
Hiimy texts is following
Execution/428/2019DOI:05-07-20192 years 5 months 4
daysCompliance23-09-2019

I want to delete whole texts after DOI:
This comment was minimized by the moderator on the site
Hi I have the next text:
/credit-loan/super-credit/- from 1251 to 1016( -18.78%)
/credit-loan/no-credit/- from 1018 to 703( -30.94%)
/loan-loan-credit-cards- from 773 to 633( -18.11%)
/loan-loan/fair-loan/- from 321 to 502( -29.69%)

I need to delete everything after "-" before the from, including the character "-" so the above to become:
/credit-loan/super-credit/
/credit-loan/no-credit/
/loan-loan-credit-cards
/loan-loan/fair-loan/

And after I would also need to have the above without the "/" as in (but I think I can manage that later):
/credit-loan/super-credit
/credit-loan/no-credit
/loan-loan-credit-cards
/loan-loan/fair-loan
This comment was minimized by the moderator on the site
Thank you!
This comment was minimized by the moderator on the site
What is the formula to keep only 160USCAIRAPPW01 in below excel spreadsheet?

16780187,160-USC-NOV-Updates-Server,160 - ALL LAC+USC Servers,160USCAIRAPPW01,Non-compliant,11/23/2019 11:33 AM,,,,,,16891741,Non-compliant,0X00000000,Success,11/23/2019 11:22 AM,(SYSTEM),Yes,No,Yes,
This comment was minimized by the moderator on the site
remove everything before
the last hyphen?
BABU RAM (622)
JAGAN NATH
This comment was minimized by the moderator on the site
I have: E4U19-31C20010093021EI 3032AER LINGUS 190805000010. I need to remove everything before the first space and everything after the last space but I need to keep the spaces. I have this formula but it removes the spaces: =LEFT(RIGHT(A19,LEN(A19)-FIND(" ",A19)),FIND("^^",SUBSTITUTE(RIGHT(A19,LEN(A19)-FIND(" ",A19))," ","^^",LEN(RIGHT(A19,LEN(A19)-FIND(" ",A19)))-LEN(SUBSTITUTE(RIGHT(A19,LEN(A19)-FIND(" ",A19))," ",""))))-1)
This comment was minimized by the moderator on the site
Hi, please try this formula:
=LEFT(RIGHT(B9,LEN(B9)-FIND(" ",B9)+1),FIND("^^",SUBSTITUTE(RIGHT(B9,LEN(B9)-FIND(" ",B9))," ","^^",LEN(RIGHT(B9,LEN(B9)-FIND(" ",B9)))-LEN(SUBSTITUTE(RIGHT(B9,LEN(B9)-FIND(" ",B9))," ",""))))-1)
This comment was minimized by the moderator on the site
Great buddy. Too much helpful post.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations