How to Remove Leading Letters/Characters

meppwc

Well-known Member
Joined
May 16, 2003
Messages
626
Office Version
  1. 365
Platform
  1. Windows
I am trying to find a way of removing any leading characters and letters from cells and leave only numbers
The amount of characters and letters preceding the numbers can vary.

Examples:

AW12345
A12345
AW#12345
etc, etc, etc
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I am trying to find a way of removing any leading characters and letters from cells and leave only numbers
The amount of characters and letters preceding the numbers can vary.

Examples:

AW12345
A12345
AW#12345
etc, etc, etc
Are you looking for a formula that looks at a cell and displays the number from it? If so, try this one..

=MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),99)
 
Upvote 0
Thank you Rick........that formula works great, much appreciated
 
Upvote 0
Are you looking for a formula that looks at a cell and displays the number from it? If so, try this one..

=MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),99)

Cool formula. Would you mind explaining why if I leave out the &"0123456789" piece that an error is given? My understanding of it is that you add all the numbers to cover the bases, but in the case of AW12345 then the 1 should be recognised.
 
Upvote 0
Cool formula. Would you mind explaining why if I leave out the &"0123456789" piece that an error is given? My understanding of it is that you add all the numbers to cover the bases, but in the case of AW12345 then the 1 should be recognised.

FIND errors out if it cannot find what it is searching for. Find iterates the {0,1,2,3,4,5,6,7,8,9} constant array and if it cannot find a the number in the array it is currently looking for, it would error out, but since we concatenated "0123456789" onto the A1 reference, it is guaranteed to find each digit it searches for. Since FIND returns the position of the text it is searching for, the MIN function guarantees the location of the first digit in A1 is returned to the MID function. Note that if no digits exist in the text, the empty string ("") is returned from the MID function because the found digit in that case will be one of the concatenated digits and the position of each of those is past the end of the text.
 
Upvote 0
Thanks for the quick response Rick. I have the concept now, I just wanted to understand the logic.
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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