How to extract only the different part of a number/string

feni1388

Board Regular
Joined
Feb 19, 2018
Messages
61
Office Version
  1. 2021
Platform
  1. Windows
Hello...

I have a data that contains a number or maybe a combination of a alphabet and number.
I want to extract only the different part of the number.
I can't use right function, because it might be only 1 digit or 2 digits or maybe 3 digits that are different in that group.
Has anyone any idea what function is best to use in this case?

Order codewhat I want to extract is
GV3431 group3
GV3433
GV3433
GV3433
GV3433
GV3444
GV3444
38776001 group0
38776000
38776000
38776000
38776000
387761010
387761010
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I can't use right function, because it might be only 1 digit or 2 digits or maybe 3 digits that are different in that group.
If there is a way to tell Excel when to extract how many digits, we can merge RIGHT function within IFS function to get the desired results.

Trick is how to tell Excel when to extract what...
 
Upvote 0
Maybe:

Book1
ABC
1Order codewhat I want to extract is
2GV3431 group3
3GV3433
4GV3433
5GV3433
6GV3433
7GV3444
8GV3444
938776001 group00
10387760000
11387760000
12387760000
13387760000
14387761010
15387761010
Sheet3
Cell Formulas
RangeFormula
C2:C15C2=LET(rng,A2:A8,len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mm,MMULT(mat+0,TRANSPOSE(s)^0),mn,MIN(mm),RIGHT(rng,len-mn))
Dynamic array formulas.


It's kind of tricky to figure out what the maximum common section is. This formula requires that you enter the range for each group. That's because I don't know where each group starts and ends, and also because it's a Spill formula, so the results will spill down each group. I might be able to figure something out if you can tell me a definite way to know when each group starts/ends.
 
Upvote 0
Maybe:

Book1
ABC
1Order codewhat I want to extract is
2GV3431 group3
3GV3433
4GV3433
5GV3433
6GV3433
7GV3444
8GV3444
938776001 group00
10387760000
11387760000
12387760000
13387760000
14387761010
15387761010
Sheet3
Cell Formulas
RangeFormula
C2:C15C2=LET(rng,A2:A8,len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mm,MMULT(mat+0,TRANSPOSE(s)^0),mn,MIN(mm),RIGHT(rng,len-mn))
Dynamic array formulas.


It's kind of tricky to figure out what the maximum common section is. This formula requires that you enter the range for each group. That's because I don't know where each group starts and ends, and also because it's a Spill formula, so the results will spill down each group. I might be able to figure something out if you can tell me a definite way to know when each group starts/ends.
Sorry, there's supposed to be a customer code to differentiate each group.

Order codeCustomer codewhat I want to extract is
GV343FPC010063
GV343FPC010063
GV343FPC010063
GV343FPC010063
GV343FPC010063
GV344FPC010064
GV344FPC010064
3877600FPC010070
3877600FPC010070
3877600FPC010070
3877600FPC010070
3877600FPC010070
3877610FPC0100710
3877610FPC0100710
 
Upvote 0
Try this:

Book1
ABC
1Order codeCustomer codewhat I want to extract is
2GV343FPC010063
3GV343FPC010063
4GV343FPC010063
5GV343FPC010063
6GV343FPC010063
7GV344FPC010064
8GV344FPC010064
93877600FPC0100700
103877600FPC0100700
113877600FPC0100700
123877600FPC0100700
133877600FPC0100700
143877610FPC0100710
153877610FPC0100710
16
17
Sheet3
Cell Formulas
RangeFormula
C2:C15C2=LET(cc,B2,rng,FILTER($A$2:$A$100,$B$2:$B$100=cc),ix,COUNTIF(B$2:B2,cc),len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mn,MIN(MMULT(mat+0,TRANSPOSE(s)^0)),RIGHT(INDEX(rng,ix),len-mn))


This seems to work ok. It's not a spill formula, you'll have to drag it down the column. It's pretty complicated, I worry a bit that it'll slow your sheet if you have a lot of rows, but try it and see.

Edit: another thought - can the customer code appear in the column for multiple groups? If so, that will be an issue.
 
Upvote 0
Solution
Try this:

Book1
ABC
1Order codeCustomer codewhat I want to extract is
2GV343FPC010063
3GV343FPC010063
4GV343FPC010063
5GV343FPC010063
6GV343FPC010063
7GV344FPC010064
8GV344FPC010064
93877600FPC0100700
103877600FPC0100700
113877600FPC0100700
123877600FPC0100700
133877600FPC0100700
143877610FPC0100710
153877610FPC0100710
16
17
Sheet3
Cell Formulas
RangeFormula
C2:C15C2=LET(cc,B2,rng,FILTER($A$2:$A$100,$B$2:$B$100=cc),ix,COUNTIF(B$2:B2,cc),len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mn,MIN(MMULT(mat+0,TRANSPOSE(s)^0)),RIGHT(INDEX(rng,ix),len-mn))


This seems to work ok. It's not a spill formula, you'll have to drag it down the column. It's pretty complicated, I worry a bit that it'll slow your sheet if you have a lot of rows, but try it and see.

Edit: another thought - can the customer code appear in the column for multiple groups? If so, that will be an issue.
Thank you.
It seems to work OK.... I still need to try it with actual data though.... which it will be quite a long list.
Regarding to the customer code, it will appear in several rows randomly, but I will sort it first before applying the formula that you gave me.
So I think it's going to be OK.
 
Upvote 0
What I mean was, can you have a situation like this?

Book1
ABC
1Order codeCustomer codewhat I want to extract is
2GV343FPC01006GV343
3GV343FPC01006GV343
4GV343FPC01006GV343
5GV343FPC01006GV343
6GV343FPC01006GV343
7GV344FPC01006GV344
8GV344FPC01006GV344
93877600FPC0100700
103877600FPC0100700
113877600FPC0100700
123877600FPC0100700
133877600FPC0100700
143877610FPC0100710
153877610FPC0100710
16ABC123FPC01006ABC123
17ABC122FPC01006ABC122
18ABC124FPC01006ABC124
Sheet3
Cell Formulas
RangeFormula
C2:C18C2=LET(cc,B2,rng,FILTER($A$2:$A$100,$B$2:$B$100=cc),ix,COUNTIF(B$2:B2,cc),len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mn,MIN(MMULT(mat+0,TRANSPOSE(s)^0)),RIGHT(INDEX(rng,ix),len-mn))


Same customer number, 2 different groups with different formats. If not, you should be ok. In fact, you shouldn't need to sort your data if you don't want to.
 
Upvote 0
What I mean was, can you have a situation like this?

Book1
ABC
1Order codeCustomer codewhat I want to extract is
2GV343FPC01006GV343
3GV343FPC01006GV343
4GV343FPC01006GV343
5GV343FPC01006GV343
6GV343FPC01006GV343
7GV344FPC01006GV344
8GV344FPC01006GV344
93877600FPC0100700
103877600FPC0100700
113877600FPC0100700
123877600FPC0100700
133877600FPC0100700
143877610FPC0100710
153877610FPC0100710
16ABC123FPC01006ABC123
17ABC122FPC01006ABC122
18ABC124FPC01006ABC124
Sheet3
Cell Formulas
RangeFormula
C2:C18C2=LET(cc,B2,rng,FILTER($A$2:$A$100,$B$2:$B$100=cc),ix,COUNTIF(B$2:B2,cc),len,MAX(LEN(rng)),s,SEQUENCE(,len),m,MID(INDEX(rng,1),1,s),mat,m=LEFT(rng,s),mn,MIN(MMULT(mat+0,TRANSPOSE(s)^0)),RIGHT(INDEX(rng,ix),len-mn))


Same customer number, 2 different groups with different formats. If not, you should be ok. In fact, you shouldn't need to sort your data if you don't want to.
No, there shouldn't be any situation like this. The same customer code will have order code in sequence.
Thank you for your concern.
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,653
Members
449,111
Latest member
ghennedy

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