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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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
Biff - you are some kind of legend.

Thanks much and all the best

Frierpie
 
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,216,190
Messages
6,129,421
Members
449,509
Latest member
ajbooisen

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