跳到主要內容

如何將一個單元格中的文本和數字分成兩列?

現在,如果有一列由文本和數字組成的文本字符串,那麼您希望將文本和數字從一個單元格分離為兩個不同的單元格,如下面的屏幕快照所示。 在Excel中,您可以使用以下方法完成此任務。


方法1:用Excel中的公式分隔文本和數字

使用以下公式,您可以將文本和數字從單元格提取到兩個單獨的單元格中。 請執行以下操作:

1。 將此公式輸入到要放置結果的空白單元格C3中: =左(A3,MIN(查找(0,1,2,3,4,5,6,7,8,9 {},A3&"0123456789"))-1)A3 是包含要分隔的文本字符串的單元格,然後按 Enter 鍵以僅從單元格A2中獲取文本。 看截圖:

doc分割文字編號2

2.然後,您可以通過應用以下公式從單元格中提取數字: =右(A3,LEN(A3)-MIN(查找(0,1,2,3,4,5,6,7,8,9 {},A3&"0123456789"))+1),( A3 是包含要分隔的文本字符串的單元格),將此公式輸入到要放置數字的單元格D3中,然後按 Enter 密鑰,那麼您將獲得如下數字:

doc分割文字編號3

3。 然後選擇單元格C3:D3,然後將填充手柄拖到要包含這些公式的單元格上,您會看到文本和數字已分為不同的單元格:

doc分割文字編號4


將文本字符串拆分或分離為單獨的文本和數字列:

Excel的Kutools's 分裂細胞 該功能是一個功能強大的工具,它可以幫助您將單元格值拆分為多列或多行,還可以幫助您將字母數字字符串拆分為單獨的文本和數字列等。 點擊下載Kutools for Excel!

doc分割文字編號16

方法2:在Excel 2013和更高版本中使用Flash Fill分隔文本和數字

使用上述公式,如果文本在數字之前,則可以將文本和數字分開。 要分隔文本字符串,其前面的數字是數字,您可以使用 Flash填充 Excel 2013和更高版本的功能。

如果您擁有Excel 2013及更高版本, Flash填充 該功能可能會幫助您在一個列中填充文本,在另一列中填充數字,請按照以下步驟操作:

1。 將您的第一個文本字符串的數字完全輸入到相鄰的空白單元格-B3中,請參見屏幕截圖:

doc分割文字編號5

2。 然後選擇要填充數字的區域B3:B7,然後單擊 數據 > Flash填充,並且一次只在單元格中填寫了數字,請參見屏幕截圖:

doc分割文字編號6

3。 然後將文本字符串完全輸入到單元格C3中,請參見屏幕截圖:

doc分割文字編號7

4. 並選擇要僅填充文本的單元格區域C3:C7,單擊 數據 > Flash填充 以及第2步,您可以看到,文本已如下分離:

doc分割文字編號8

尖端:您還可以將填充的手柄拖到要使用的範圍,然後單擊 自動填充選項 並檢查 Flash填充.

doc分割文字編號9

方法3:用用戶定義的功能將不規則混合的文本和數字分開

如果您有一些文本字符串不規則地混合了文本和數字,例如顯示的以下數據,則Excel不支持一般功能來解決此問題,但是,您可以創建用戶定義函數來完成此操作。

doc分割文字編號17

1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:將文本和數字從一個單元格分成不同的單元格

Public Function SplitText(pWorkRng As Range, pIsNumber As Boolean) As String
'Updateby Extendoffice
Dim xLen As Long
Dim xStr As String
xLen = VBA.Len(pWorkRng.Value)
For i = 1 To xLen
    xStr = VBA.Mid(pWorkRng.Value, i, 1)
    If ((VBA.IsNumeric(xStr) And pIsNumber) Or (Not (VBA.IsNumeric(xStr)) And Not (pIsNumber))) Then
        SplitText = SplitText + xStr
    End If
Next
End Function

3。 然後保存並關閉此代碼,返回工作表,輸入此公式 = SplitText(A3,FALSE) 進入空白單元格以獲取唯一的文本字符串,然後將填充手柄向下拖動到要填充此公式的單元格,請參見屏幕截圖:

doc分割文字編號10

4。 然後輸入公式 = SplitText(A3,TRUE) 到另一個單元格中,然後將填充手柄向下拖動到要填充此公式以獲取數字的單元格,請參見屏幕截圖:

doc分割文字編號11

備註:如果文本字符串中有十進制數字,則結果將不正確。


方法4:使用Kutools for Excel將文本和數字分成兩列

如果你有 Excel的Kutools,其功能強大的工具- 分裂細胞 實用程序,您可以將文本字符串快速分為兩列:一是數字,另一是文本。

安裝後 Excel的Kutools,請執行以下操作:

1。 選擇要分隔文本和數字的數據范圍。

2。 然後點擊 庫工具 > 合併與拆分 > 分裂細胞,請參見屏幕截圖:

3。 在 分裂細胞 對話框中選擇 拆分為列 選項下 類別 部分,然後檢查 文字和數字 來自 分割為 部分,請參見屏幕截圖:

doc分割文字編號13

4。 然後點擊 Ok 按鈕,然後會彈出提示框,提醒您選擇一個單元格以輸出結果,請參見屏幕截圖:

doc分割文字編號14

5。 點擊 OK 按鈕,所選內容中的文本字符串已分為兩列,如以下屏幕截圖所示:

doc分割文字編號15

點擊立即下載Kutools for Excel並免費試用!


使用Kutools for Excel分隔文本和數字

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

相關文章:

如何在Excel中將單詞拆分為單獨的字母?

如何通過回車將單元格分為多列或多行?


 

  • Kutools for Excel:300多個免費試用版的Excel便捷功能

    它為Excel收集了300多種智能專業工具,可將各種複雜任務簡化為您在日常工作中的幾次單擊,從而可以節省大量時間並提高生產率。

    • 將多個工作表或工作簿合併為一個工作簿或工作表
    • 根據背景,字體或條件格式顏色對單元格進行計數和求和
    • 將相同的電子郵件分別發送到帶有不同附件的收件人列表
    • 110,000多個Excel用戶的選擇。 全功能30天免費試用,無需信用卡!
    • 60 天退款保證!
    庫工具 1 kutools加
  • 將多個工作表或工作簿合併為一個工作表或工作簿

    在日常工作中,將多個工作表或工作簿合併為一張工作表或工作簿可能是一項艱鉅的工作,您需要將它們一個接一個地合併。 但是,隨著 Excel的Kutools's 結合 功能,只需單擊幾下即可解決此任務。

    合併表
  • 根據背景,字體或條件格式顏色對單元格進行計數和求和

    對於您而言,根據背景,字體或條件格式顏色在大範圍內對單元格值進行計數或求和可能是一項艱鉅的任務, Excel的Kutools 支持簡單的工具-按顏色計數 這可以幫助您在沒有任何Excel技能的情況下盡快處理此工作。

    按顏色計數
  • 將相同的電子郵件分別發送到帶有不同附件的收件人列表

    您可以應用Word應用程序將個性化電子郵件發送給沒有附件的多個人,但是, Excel的Kutools's 發電子郵件 功能,這種補救措施可以糾正。 同時,您也可以抄送或密送給特定人員的郵件。

    發電子郵件

 

Comments (34)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Tenho uma coluna com vários endereços e os números de endereços. Conforme tabela abaixo. Como separo em uma coluna apenas os nomes e outra coluna apenas os números?

endereço
Avenida Angélica 1235
Rua José Maria Lisboa 456
Rua Celso de Azevedo Marques 307
Rua Rio Duas Barras 953
This comment was minimized by the moderator on the site
Hello, Mateus,
To extract the address number only from the address, the folloiwng formula may help you:
=SUMPRODUCT(MID(0&B3, LARGE(INDEX(ISNUMBER(--MID(B3, ROW(INDIRECT("1:"&LEN(B3))), 1)) * ROW(INDIRECT("1:"&LEN(B3))), 0), ROW(INDIRECT("1:"&LEN(B3))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(B3)))/10)

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Bom dia.
Consegui extrair o número, muito obrigado!
Mas como eu consigo extrair agora apenas o endereço?
This comment was minimized by the moderator on the site
Hello, Mateus,
If you want to extract both address and address number, you can apply the Method 3 in this article:

https://www.extendoffice.com/documents/excel/2701-excel-separate-text-and-numbers.html#a3

After copying and pasting the code, please apply the below formulas:
Extract address: =SplitText(B2,FALSE)

Extract address number: =SplitText(B2,TRUE)
Please try, hope it can help you! If you have any other problem, please comment here.
This comment was minimized by the moderator on the site
Agile (11/20/2017 12:00:00 AM)How can I separate this cell into just "Agile" and "(11/20/2017 12:00:00 AM)"
This comment was minimized by the moderator on the site
Hello, Milner,To get the name text, please use this formula: =TRIM(LEFT(A1, FIND("(", A1)-1))To get the date time, please apply this formula: =MID(A1,SEARCH("(",A1),SEARCH(")",A1)-SEARCH("(",A1)+1)Please try the formulas, hope them can help you!
This comment was minimized by the moderator on the site
0002786961 TRAK CDFA #: 0008787942 2722 2723 4536841 N/A 4345784 001018809~00077480

Above is an example of data line I need to split these into 3 types: First: starts with 2 and is of 4 digit (2722 in above example) Second: starts with 2 and is of 7 digit third; starts with 4 is of 7 digit.
I tried separating everything into different columns and then putting if and conditions that I mentioned above but the problem is not everything is getting separated and splitting everything is not efficient enough. I am not able to figure out a vba code for something that satisfies all the conditions and works too.
Can anyone help me out?
This comment was minimized by the moderator on the site
Hello, menze
Do you need to split this three parts 2722 2723 4536841 from the long data? If so, you just can use the Text to Column feature in Excel to split the content into multiple cells by space, then delete the extra data and only keep the data you need.
If not, please upload your Excel file or screenshot here for a reference.
Thank you!
This comment was minimized by the moderator on the site
I have a requirement code that I need to separate out from the text, looks like this 3.1.1.2. Line-of-sight Range Requirements (T=O) The vehicle and units shall be capable of line-of-sight connectivity to all nodes or within a 10-mile radius, whichever is greater. In one column I need the code and the other I need the text. Can you help?
This comment was minimized by the moderator on the site
I have address like 12,anna street,98413256789 i want to seperate address and contact number(mobile or landline) two columns. Is it possible.Pls help to solve
This comment was minimized by the moderator on the site
Hi, Mohan,To seperate address and contact number, please apply the below formulas:Address: =LEFT(A1,LEN(A1)-12)Mobile number: =RIGHT(A1,11)
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Please, help me with the VBA code required to take out "INC000010542805" out of "User KSmith Audit ID INC000010542805 Comment None Control Data".
I have 1,000 rows of this type of data with different number of characters but always with that "INC" string.
This comment was minimized by the moderator on the site
Hello, Kenny,
May be the below formula can solve your problem, please try:
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("INC",A1),LEN(A1))," ",REPT(" ",100)),100))
This comment was minimized by the moderator on the site
skyyang thanks very much, it works. I really appreciate your help
This comment was minimized by the moderator on the site
how to separate number and letters (1122AB). I tried the upper formula but its not working with me. anybody help me in this regard. Thanks in advance
This comment was minimized by the moderator on the site
Hello, Naeem,
The above formula only works if the text is before the numbers, your numbers before the text, so i recommend the second and third method for you!
Please try, hope it can help you!
This comment was minimized by the moderator on the site
kereeeennn... berhasil....
This comment was minimized by the moderator on the site
Thanks worked for Alpha-numeric cell data [ =RIGHT(A2,LEN(A2)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))+1)]
This comment was minimized by the moderator on the site
Hello Can anyone help me? I want to remove this zero and braceket by an excel formula.
1 BR PE-0.50CT(H SI2)- -0.00( )-2 SP PE-0.50CT(H SI1)-1 RU PE-0.40CT(H-SI)-750GF-RG-RING-25-40-2.50GM


Gowtam
This comment was minimized by the moderator on the site
VERY USEFUL FORMULA I LIKE IT.
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