Extracting and Formatting Numbers from Data Rows

TheWes

New Member
Joined
Sep 20, 2024
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I need some help please.

I have many rows of data that look like this:


Raw code
18G4007
18G4008
18G4009
18G7980
18M18
18R4000
18R912

I would like to extract the numbers from the right until the alphabetic letter.
I want the extracted numbers to always be 4 digits. If there are only 2 or 3 digits before the alphabetic letter, I’d like to add 1 or 2 zeros in front, respectively.
To summarize, I’m looking for a solution that can transform the raw input:


Raw code
18G4007
18G4008
18G4009
18G7980
18M18
18R4000
18R912

New code
4007
4008
4009
7980
0018
4000
0912

Any guidance or syntax in Excel to achieve this would be greatly appreciated!

Thanks in advance!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi everyone,

I need some additional help with formatting a set of raw data. Here’s what I’m working with:

Raw Data: (+- 6000 rows)


46U4296
47M47
4D100
4D392


Desired Output:

I want to extract the first two numbers from each entry, but if the second character is an alphabetic letter, I want to put a zero in front of the extracted number.
Here’s how I’d like it to look:

New data

046
047
04
04

Any suggestions on how to achieve this would be greatly appreciated!
I can only think about some nested function, but this should be able to be done easier.
 
Upvote 0
Book1
AB
1146U4296046
1247M47047
134D10004
144D39204
Sheet1
Cell Formulas
RangeFormula
B11:B14B11="0"&AGGREGATE(14,6,LEFT(A11,{1,2,3,4})+0,1)
 
Upvote 0
You can also use the below formula :

Excel Formula:
="0"&LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1)
 
Upvote 0
Book1
AB
1146U4296046
1247M47047
134D10004
144D39204
Sheet1
Cell Formulas
RangeFormula
B11:B14B11="0"&AGGREGATE(14,6,LEFT(A11,{1,2,3,4})+0,1)
The solution above works for my initial desired output. Clear and timely. Thanks.

I did however make a mistake in my desired output.
I only want to put a zero in front of entries that only have 1 number before the alphabetic number. The other entries I simply want to extract the first 2 number characters.

Raw Data: (+- 6000 rows)
46U4296
47M47
4D100
4D392

Desired Output:
46
47
04
04

Thanks.
 
Upvote 0
You can also use the below formula :

Excel Formula:
="0"&LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1)
The solution above works for my initial desired output. Clear and timely. Thanks.
FYI only, I responded to bebo also with a slight tweak.
 
Upvote 0
You can try the below formula :

Excel Formula:
=IF(LEN(LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1))=1,"0"&LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1),LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1))

or you can use the below :

Excel Formula:
=TEXT(LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1),"00")
 
Last edited:
Upvote 0
You can try the below formula :

Excel Formula:
=IF(LEN(LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1))=1,"0"&LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1),LEFT(A11,MATCH(TRUE,ISERROR(VALUE(MID(A11,ROW(INDIRECT("1:"&LEN(A11))),1))),0)-1))

Thank you, I tried both syntax but both are not working sadly.
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,051
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