Extracting Number String from a Text String Cell

Chubba

New Member
Joined
Jul 12, 2011
Messages
20
Office Version
  1. 2010
Platform
  1. Windows
Hi

I have a list of cells with text that contains a 9 digit number that I'd like to extract. The issue I have is that this 9 digit reference can appear anywhere in the cell and further complicated in that the cell could contain other numerical characters which I won't need so, for example, it may look like (highlighted in bold the number I wish to extract):

Test 259 7456 20 alpha
Test on 22/09/22 964 5489 30
258 6321 95
completed 3 December
15 June begin 967 5841 32 over

I was thinking perhaps there could be a way to extract the number that fits the format "xxx xxxx xx". Is that possible for Excel 2010?

Thanks
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If your first number is in cell A1, you can try the following formula and then pull down the formula :
Excel Formula:
=IFERROR(MID(A1,SEARCH("??? ???? ??",A1),11),"NA")
 
Upvote 0
That won't restrict to numbers though. If you had:

new Test 259 7456 20 alpha

it would return "new Test 25" and not the number.
 
Upvote 0
Thank you Sanjeev1976. That worked for 95% of the cases and was just about to post exactly what RoryA has said. While that didn't appear in my examples, that is a possibility so is there a way to search "??? ???? ??" but restrict to just numbers?

Thanks again
 
Upvote 0
Which version of Excel do you have?
 
Upvote 0
I suggest you update your profile to include that, as it will restrict a lot of the options you would have available with more current versions.
 
Upvote 0
I suggest you update your profile to include that, as it will restrict a lot of the options you would have available with more current versions.
Thanks for the advice. Now updated
 
Upvote 0
You could try a UDF like this:

Code:
Function GetNum(checkVal As String) As String
   If checkVal Like "*### #### ##*" Then
      With CreateObject("vbscript.regexp")
         .Pattern = "\d{3} \d{4} [\d]{2}"
         .Global = True
         GetNum = .Execute(checkVal)(0)
      End With
   End If
End Function

Used as =GetNum(A1)
 
Upvote 0

Forum statistics

Threads
1,223,716
Messages
6,174,069
Members
452,542
Latest member
Bricklin

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