How to Separate Numbers Using Formula in Excel: 5 Ways

Method 1 – Using Combined Excel Formula

1.1 Separate Numbers After Text

Steps:

  • At the very beginning, go to the C5 cell >> enter the formula given below.

=RIGHT(B5,LEN(B5)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&"0123456789"))+1)

The B5 cell refers to the text Microsoft Office 95.

Formula Breakdown:

  • FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″) → returns the starting position of one text string within another text string. Here, {0,1,2,3,4,5,6,7,8,9} is the find_text argument while B5&”0123456789″ is the within_text argument. The FIND function returns the position of the numeric values in the string of text.
  • MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″)) returns the smallest number in a set of values. The FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″) is the number_1 argument and the MIN function returns the smallest value within this array.
    • Output → 18
  • LEN(B5) → returns the number of characters in a string of text. The B5 cell is the text argument which yields the value 19.
    • Output → 19
  • LEN(B5)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″))+1 becomes
    • 19 – 18 + 1 → 2
  • RIGHT(B5,LEN(B5)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″))+1) becomes
    • RIGHT(B5,2)  returns the specified number of characters from the end of a string. The B5 cell is the text argument 2 is the num_chars argument that the function returns the 2 characters from the right side.
    •  Output → 95

Separate Numbers After Text

  • Use the Fill Handle Tool to copy the formula into the cells below.

Using Fill Handle tool

The results should look like the image given below.

how to separate numbers in excel using formula with FIND, LEN, MIN, and RIGHT functions


1.2 Separate Numbers Preceding Text

Steps:

  • Move to the C5 cell >> type in the expression given below.

=LEFT(B5,SUM(LEN(B5)-LEN(SUBSTITUTE(B5,{"0","1","2","3","4","5","6","7","8","9"},""))))

The B5 cell indicates the text 95 Microsoft Office.

Formula Breakdown:

  • SUBSTITUTE(B5,{“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″},””) → replaces existing text with new text in a text string. Here, the B5 refers to the text argument while Next, the {“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9”} represents the old_text argument, and the “” points to the new_text argument which is left blank.
  • LEN(SUBSTITUTE(B5,{“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″},””)) → returns the number of characters in the string of text. The output from the SUBSTITUTE function is the text argument.
  • SUM(LEN(B5)-LEN(SUBSTITUTE(B5,{“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″},””))) →  adds all the numbers in a range of cells. The SUM function returns the total of the numeric values.
    • Output → 2
  • LEFT(B5,SUM(LEN(B5)-LEN(SUBSTITUTE(B5,{“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″},””)))) becomes
    • LEFT(B5,2)  returns the specified number of characters from the start of a string. The B5 cell is the text argument 2 is the num_chars argument that the function returns the 2 characters from the left side.
    •  Output → 95

Separate Numbers Preceding Text

Your output should look like the picture given below.

how to separate numbers in excel using formula with SUBSTITUTE, SUM, and LEFT functions


1.3 Separate Decimal Numbers

Steps:

  • The first place, insert the following equation into the C5 cell.

=RIGHT(B5,LEN(B5)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&"0123456789"))+1)

The B5 cell represents the text value of Microsoft Office 95.1.

Separate Decimal Numbers

After completing the above step, the output should look like the screenshot below.

how to separate numbers in excel using formula applying FIND, LEN, MIN, and RIGHT functions


Method 2 – Utilizing Flash Fill Feature

Steps:

  • The first place, manually type in the first ID number which is 1214 in the C5 cell so that Excel can recognize a pattern.
  • Navigate to the C6 and enter the first two digits of 1215 and Excel will show a preview of the autofill results >> hit the ENTER key.

Manually entering data

The results should look like the image given below.

how to separate numbers in excel using formula with Flash Fill feature


Method 3 – Employing Text to Columns Feature

3.1 Applying Delimiters Option

Steps:

  • Select the B5:B13 cells >> proceed to the Data tab >> click the Text to Columns option.

The B5:B13 cells point to the ID and Names columns.

Applying Delimiters Option

This opens the Convert Text to Columns wizard.

  • Choose the Delimited option >> hit the Next button.

Text to column wizard step 1

  • Insert a check mark for the Space delimiter >> press the Next button.

Text to column wizard step 2

  • Enter a Destination cell according to your preference, it is the C5 cell >> click Finish.

Text to column wizard step 3

The results should appear in the picture shown below.

how to separate numbers in excel using formula with delimited option


3.2 Utilizing Fixed Width Feature

Steps:

  • Select the C5:C14 cells >> jump to the Data tab >> press the Text to Columns option.

The C5:C14 cells point to the Employee ID column.

Go to Text to Column option

The Convert Text to Columns wizard pops out.

  • Select the Fixed Width option >> press the Next button.

Select Fixed Width option

  • Left click to insert column breaks after the Code and ID >> click the Next button.

Insert column breaks

  • Select the Destination cell, for example, the D5 cell >> hit the Finish button.

select destination

The end result should look like the screenshot provided below.

how to separate numbers in excel using formula with Fixed Width option


Method 4 – Using Power Query Editor

Steps:

  • Select the B4:B13 cells >> hit the keyboard shortcut CTRL + T to insert an Excel Table >> press OK.

Using Power Query Editor

  • Go to the B4 cell >> in the Data tab, click the From Table/Range option.

Select From Table/Range

The Power Query Editor window appears.

  • Move to the Transform tab >> press the Split Column drop-down >> choose the By Non-Digit to Digit option.

Go to Transform

  • Double-click the column headers to rename them >> press the Close & Load option to exit the Power Query window.

Close and Load data

The output should look like the image depicted below.

how to separate numbers in excel using formula with Power Query


Method 5 – Applying VBA Code

Steps:

  • Navigate to the Developer tab >> click the Visual Basic button.

Applying VBA Code

This opens the Visual Basic Editor in a new window.

  • Go to the Insert tab >> select Module.

Inserting Module

You can copy the code from here and paste it into the window as shown below.

Function SplitNumAndText(str As String, op As Boolean)
num = ""
   txt = ""
   For i = 1 To Len(str)
       If IsNumeric(Mid(str, i, 1)) Then
            num = num & Mid(str, i, 1)
Else
            txt = txt & Mid(str, i, 1)
     End If
    Next i
If op = True Then
    SplitNumAndText = num
Else
    SplitNumAndText = txt
End If
End Function

VBA code window

Code Breakdown:

The VBA code used to separate numbers. In this case, the code is divided into 2 steps.

  • Declare the function SplitNumAndText where the first argument is a string and the second argument a Boolean type.
  • Iterate through the whole string using For loop and If statement to check if the value is a number or not.
  • In the later portion, use a second If statement to return output (Number or Text) based on the second argument. Passing 0 as the second argument will extract the Text while passing 1 returns the Number from the given string.

Code explanation

  • Close the VBA window >> navigate to the C5 cell >> insert the function below.

=SplitNumAndText(B5,1)

The B5 cell refers to the ID and Names value of 1214 John Connor.

Using SplitNumAndText function

Yield the results shown in the screenshot below.

how to separate numbers in excel using formula with VBA Code


How to Split Numbers Using Formula in Excel

Steps:

  • Jump to the D5 cell >> insert the expression into the Formula Bar.

=MID($C5,COLUMN()-(COLUMN($D5)- 1),1)

The C5 cell indicate the ID number 1214.

Formula Breakdown:

  • COLUMN()-(COLUMN($D5)- 1) → returns the column number of a cell reference.
    • 4 – (4-1) → 1
  • MID($C5,COLUMN()-(COLUMN($D5)- 1),1) becomes
    • MID($C5,1,1)  returns the characters from the middle of a text string, given the starting position and length. The C5 cell is the text argument, 1 is the start_num argument, and 1 is the num_chars argument, so the function returns the first character from the left side.
    •  Output → 1

How to Split Numbers in Excel Using Formula

  • Drag the Fill Handle tool across the rows to insert the remaining numbers.

Applying Fill Handle

  • Select the D5:G5 cells and again use the Fill Handle tool to complete the table.

The final output should look like the following screenshot.

how to separate numbers in excel using formula using MID and COLUMN functions


How to Split Numbers into Two Columns in Excel

Steps:

  • Select the C5:C13 cells >> navigate to the Data tab >> click the Text to Columns option.

Move to Text to Column option

  • Select the Fixed Width option >> press the Next button.

Applying Fixed Width

  • Left click to insert column breaks after the Birth Year >> click the Next button.

Insert column break

  • Select the Destination cell, like the D5 cell >> hit the Finish button.

choose location

Your results should look like the image shown below.

how to separate numbers in excel using formula with Text to Column Fixed Width option

 


Download Practice Workbook


<< Go Back to Separate Numbers Text | Split | Learn Excel

 

 

 

 

 

 

 

 

 

 

 

 

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdullah Al Murad
Md. Abdullah Al Murad

Md. Abdullah Al Murad is a computer engineer who loves exploring Excel and VBA programming. Programming, to him, is a time-saving tool for efficiently managing data, files, and internet tasks. He is proficient in C, C++, Python, JavaScript, HTML, SQL, MySQL, PostgreSQL, Microsoft Office, and VBA and goes beyond the basics. He holds a B.Sc. in Computer Science and Engineering from American International University-Bangladesh. He has transitioned into the role of a content developer. Beyond his work, find... Read Full Bio

2 Comments
  1. Hi,

    Good day!

    I tried to use column to text method to separate a range of numbers in a cell(A1) and it works well on B1,C1,D1… But if I change the range of numbers in A1 again, the rest of the column does not change. May I know why? How can I have the rest of the column refresh with new numbers when I change the range of numbers in A1

    • Hello Edmund Goh,
      Thank you for sharing your problem with us. I assume you have properly gone through the steps to separate numbers with the Text to Columns feature. The reason that any changes are not updating is because the Text to Columns feature is static and it will not take any changes from the source cell. Yes, this is a limitation of this feature. You will also face the same if you apply the Flash Fill feature. In this case, I will suggest you to apply any other methods from this article except Method 4 and 5. Then you will be able to get changes on the separated numbers from the text.
      Let us know if it helps you.
      Thank you.

      Regards,
      Guria
      ExcelDemy.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo