split word and number into col

smallxyz

Active Member
Joined
Jul 27, 2015
Messages
392
Office Version
  1. 2021
Platform
  1. Windows
I have data as shown belows and wanna split them into columns, one for words, another for numbers.


Excel 2010
AB
1aaa aaaa aaaaaaaaa 123
2aaaaaaa aaaa 12345
3aaa aa 1234567
4aaaaaaaaaa aaaaaa 123
5aaa aaaa aaa aaaaaaa aaa a aa 12
6
7
8
9aaa aaaa aaaaaaaaa123
10aaaaaaa aaaa12345
11aaa aa1234567
12aaaaaaaaaa aaaaaa123
13aaa aaaa aaa aaaaaaa aaa a aa12
Sheet1


How can I?

Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Book1
ABC
1aaa aaaa aaaaaaaaa 123aaa aaaa aaaaaaaaa123
2aaaaaaa aaaa 12345aaaaaaa aaaa12345
3aaa aa 1234567aaa aa1234567
4aaaaaaaaaa aaaaaa 123aaaaaaaaaa aaaaaa123
5aaa aaaa aaa aaaaaaa aaa a aa 12aaa aaaa aaa aaaaaaa aaa a aa12
Sheet1
Cell Formulas
RangeFormula
B1=TRIM(LEFT(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1))
C1=MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),LEN(A1))


WBD
 
Upvote 0
Here is a VBA macro that takes input from Sheet1 and output to Sheet2.
Assume only one numeric in each string.

Here is the code.

Sub split_alpha_num()

Dim alpha_num As Variant
Dim i As Integer, j As Integer
Dim alpha_string As String

i = 1

While ThisWorkbook.Sheets("Sheet1").Cells(i, 1) <> ""
alpha_num = Split(ThisWorkbook.Sheets("Sheet1").Cells(i, 1), " ")
alpha_string = ""
For j = 0 To UBound(alpha_num)
If Not IsNumeric(alpha_num(j)) Then
alpha_string = alpha_string & " " & alpha_num(j)
End If
Next j
ThisWorkbook.Sheets("Sheet2").Cells(i, 1) = alpha_string
For j = 0 To UBound(alpha_num)
If IsNumeric(alpha_num(j)) Then
ThisWorkbook.Sheets("Sheet2").Cells(i, 2) = alpha_num(j)
Exit For
End If
Next j
i = i + 1
Wend

End Sub
 
Upvote 0
Hi WBD, your solution works well.
It is observed that there is no need for Ctrl + Shift + Enter for this formula.
Why is that so?
Thanks.
 
Upvote 0
Is the number that you want always after the last space in the text? If so, here is another solution you may want to consider (the formulas should be more efficient than what you have now)...

B1: =SUBSTITUTE(A1," "&C1,"")

C1: =TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",200)),200))
 
Last edited:
Upvote 0
Hi WBD, your solution works well.
It is observed that there is no need for Ctrl + Shift + Enter for this formula.
Why is that so?
Thanks.

The SEARCH() function takes an array constant of {0,1,2,3,4,5,6,7,8,9} which causes the SEARCH() to be executed 10 times and then the MIN() function takes the lowest value.

WBD
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top