Extracting numbers, with a twist...!

L

Legacy 171839

Guest
Hi all,

So, I'm looking to extract phone numbers from a long list of company and number in the same cell.

I have various formuals to extract numbers from cells, but none are working, and here's why:

Firstly, all the formulas I try ignore the '0' at the start of the number

Example: Cell contains "Company A 0800123456" - formula returns "800123456".

Secondly, the format in which the company name/number has been entered is not always the same - ie, sometimes the number has spaces. That gives me the follwoing problem:

Example 2: Cell contains "Company B 0800 123 456" - formula returns "800"
Cell contains "Company C 08123 456654 " - formula returns "8123"

So basically, I'm looking for help to extract the full phone number from the cell, regardles of how its been inputted.

Thanks in advance for your help guys, you haven't let me down yet.

Frierpie
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi all,

So, I'm looking to extract phone numbers from a long list of company and number in the same cell.

I have various formuals to extract numbers from cells, but none are working, and here's why:

Firstly, all the formulas I try ignore the '0' at the start of the number

Example: Cell contains "Company A 0800123456" - formula returns "800123456".

Secondly, the format in which the company name/number has been entered is not always the same - ie, sometimes the number has spaces. That gives me the follwoing problem:

Example 2: Cell contains "Company B 0800 123 456" - formula returns "800"
Cell contains "Company C 08123 456654 " - formula returns "8123"

So basically, I'm looking for help to extract the full phone number from the cell, regardles of how its been inputted.

Thanks in advance for your help guys, you haven't let me down yet.

Frierpie
Try this...

Book1
*AB
2Company A 08001234560800123456
3Company B 0800 123 4560800 123 456
4Company C 08123 45665408123 456654
Sheet1

This formula entered in B2 and copied down:

=MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890)),20)
 
Last edited:
Upvote 0
I would run VBA on the cells to extract the numbers and store the values in an adjacent cell. This would work if the Company names don't have numbers.

Dim stri, striIndex, letterj

for i=1 to numberofdataentries
n=get the length of the string for the cell​
stri = cells(i,1)​

'loop through the elements inside each cell
for j=1 to n​
striIndex = Left(stri, j)​
letterj= Right(striIndex, 1)​
is letterj a number?​
if so, stri= stri+letterj​
Next j​

cells(i,2) = stri​
next i

Hopefully this approach isn't too novice. Good luck.

Jessica
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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