跳到主要內容

如何從Excel的單元格中刪除特定字符之前或之後的文本?

本文介紹了從Excel單元格中刪除特定字符或第n個出現字符之前或之後的文本的不同方法。


通過在Excel中查找和替換來刪除特定字符之前或之後的文本

要使用“查找和替換”功能刪除特定字符之前或之後的所有文本,請執行以下操作。

1.選擇要刪除特定字符之前或之後的文本的單元格,按 按Ctrl + H 鍵打開 查找和替換 對話。

在“查找和替換”對話框中:

1.要刪除逗號之前的所有特定字符,請鍵入 *, 查找內容 文本框;

2.要刪除逗號等特定字符後的所有字符,請鍵入 ,*查找內容 文本框;

筆記:

1.您可以根據需要將逗號更改為任何字符。

2.在這種情況下,最後一個逗號之前或之後的所有文本將從選定的單元格中刪除。

2。 保持 更換 文本框為空,然後單擊 “全部替換” 按鈕。 看截圖:


輕鬆刪除Excel中單元格中的所有數字,非數字或指定字符

Kutools用於 Excel's 移除角色 實用程序可幫助您輕鬆刪除Excel中選定單元格中的所有數字,非數字或指定字符。
立即下載Kutools for Excel的全功能30天免費試用版!


通過公式刪除第一個/最後一個特定字符之前或之後的文本

本部分將向您顯示刪除Excel單元格中第一個/最後一個特定字符之前或之後的所有內容的公式。

刪除第一個逗號之前的所有內容, 請:

選擇一個空白單元格,將以下公式複制並粘貼到其中,然後按 Enter 鍵。 然後拖動 填充手柄 將公式應用於其他單元格。 看截圖:

公式: 在第一個逗號之前刪除所有內容

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

筆記:

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

2.要刪除最後一個特定字符之前的所有字符,請使用以下公式:

=右(B5,LEN(B5)-FIND(“ @”,SUBSTITUTE(B5,"性格“,” @“,(LEN(B5)-LEN(替換(B5,"性格“,”“))))/ LEN(”性格“))))

刪除第一個逗號後的所有內容, 請:

選擇一個空白單元格,將以下公式複制並粘貼到其中,然後按 Enter 鍵。 然後拖動 填充手柄 將公式應用於其他單元格。 看截圖:

公式: 刪除第一個逗號後的所有內容

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

筆記:

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

2.要刪除最後一個特定字符之後的所有字符,請使用以下公式:

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


通過公式刪除第n個出現字符之前或之後的文本

下面的公式可以幫助刪除Excel單元格中第n個出現字符之前或之後的所有字符。

從單元格中刪除第n個出現字符之前的所有字符, 你需要:

選擇一個空白單元格以輸出結果,將以下公式複製到其中,然後按 Enter 鍵。 然後拖動 填充手柄 將公式應用於其他單元格。 看截圖:

公式: 在第二次出現逗號之前刪除所有內容

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

筆記:

1.在公式中 B5,“和 2 數字表示第二次出現逗號後的所有內容將從單元格B5中刪除。

2.您可以更改“,“和 2 根據需要將其編號為任何字符和出現位置編號。

從單元格中刪除第n個出現字符之後的所有字符, 你需要:

選擇一個空白單元格以輸出結果,將以下公式複製到其中,然後按 Enter 鍵。 然後拖動 填充手柄 將公式應用於其他單元格。 看截圖:


公式: 在第二次出現逗號後刪除所有內容

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

筆記:

1.在公式中 B5,“和 2 數字表示第二次出現逗號後的所有內容將從單元格A7中刪除。

2.您可以更改“,“和 2 根據需要將其編號為任何字符和出現位置編號。


使用Kutools for Excel輕鬆刪除特定字符之前/之後的文本

如果一個範圍中的每個單元格只有一個逗號分隔符,並且您想從單元格中刪除該逗號之前或之後的所有內容,請嘗試 分裂細胞 的效用 Excel的Kutools。 此實用程序將幫助您單擊幾下即可解決問題:

1.選擇要刪除逗號之前或之後的所有內容的單元格,然後單擊“確定”。 庫工具 > 文本 > 分裂細胞。 看截圖:

2。 在裡面 分裂細胞 對話框中選擇 拆分為列 在選項 類別 部分,並在 分割為 部分,選擇 其他 選項,並在空白框中鍵入逗號,然後單擊 OK 按鈕。 看截圖:

3.另一個 分裂細胞 彈出對話框,選擇一個空白單元格以查找文本,然後單擊 OK 按鈕。

然後,您可以看到所選單元格被特定字符-逗號分隔。 看截圖:

  如果您想免費試用(30天)此實用程序, 請點擊下載,然後按照上述步驟進行操作。


Kutools for Excel- 幫助您始終提前完成工作,有更多時間享受生活
您是否經常發現自己正在趕上工作,缺乏時間為自己和家人度過?  Excel的Kutools 可以幫你處理 企業排放佔全球 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