Help to get characters from different cells based on same character

gargilang

New Member
Joined
Jun 17, 2022
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hello, I would like to know if it's possible to have some formula to get the specific characters from two or three different cells based on same character in it. I am using this formula at the moment
Excel Formula:
=LEFT(A2,FIND("_",A2)-1)
to get the characters I want. for example below table:
1_aaaa_x1
2_aaaa_y2
3_bbbb_x3

Now what I want is something like this:
1_aaaa_x1, 2
2_aaaa_y2, 1
3_bbbb_x3, 4, 5
4_bbbb_y4, 3, 5
5_bbbb_z5, 3, 4

And now if it's not too much to ask already, is it also possible to have the formula to add "&" to the cell, for example:
1_aaaa_x1 & 2
2_aaaa_y2 & 1
3_bbbb_x3, 4 & 5
4_bbbb_y4, 3 & 5
5_bbbb_z5, 3 & 4
if not than it's totally okay as this is only for aesthetic.

I hope it makes sense. Kindly let me know if it's possible. Thank you for your help in advance.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi & welcome to MrExcel.
Will the text between the 2 "_" always be 4 characters?
Also can the number of digits before the 1st "_" vary?
 
Upvote 0
Hi & welcome to MrExcel.
Will the text between the 2 "_" always be 4 characters?
Also can the number of digits before the 1st "_" vary?
Thank you for warm welcome and reply.
To answer your first question, no. But it will be always either 4 or 5 characters. I am using another column to get that information as well with below formula:
Excel Formula:
=SUBSTITUTE(MID(A2,FIND("_",A2,1)+1,5),"_","")
And to your second question, yes. It is basically an order number that I am trying to get, from the table above, if item "aaaa" has 2 orders, it's Order 1 & 2. Item "bbbb" has 3 orders, order 3, 4 & 5. And let's say item "zzzz" has 4 orders, it could be order 101, 102, 103 & Pkg1.

I also attached a screenshot from the actual file that I am using. Hope it helps.
 

Attachments

  • Screenshot 2022-06-17 094009.png
    Screenshot 2022-06-17 094009.png
    20.1 KB · Views: 9
Upvote 0
Ok, how about
Fluff.xlsm
AB
1
21_aaaa_x1 & 2
32_aaaa_y2 & 1
43_bbbb_x3, 4 & 5
54_bbbb_y4, 3 & 5
65_bbbb_z5, 3 & 4
Data
Cell Formulas
RangeFormula
B2:B6B2=LET(r,$A$2:$A$6,p,FIND("_",r),m,MID(r,p+1,100),mr,MID(A2,FIND("_",A2)+1,100),f,FILTER(LEFT(r,p-1),LEFT(m,FIND("_",m)-1)=LEFT(mr,FIND("_",mr)-1)),l,LEFT(A2,FIND("_",A2)-1),SUBSTITUTE(TEXTJOIN(", ",,l,FILTER(f,f<>l)),","," &",ROWS(f)-1))
 
Upvote 0
T
Ok, how about
Fluff.xlsm
AB
1
21_aaaa_x1 & 2
32_aaaa_y2 & 1
43_bbbb_x3, 4 & 5
54_bbbb_y4, 3 & 5
65_bbbb_z5, 3 & 4
Data
Cell Formulas
RangeFormula
B2:B6B2=LET(r,$A$2:$A$6,p,FIND("_",r),m,MID(r,p+1,100),mr,MID(A2,FIND("_",A2)+1,100),f,FILTER(LEFT(r,p-1),LEFT(m,FIND("_",m)-1)=LEFT(mr,FIND("_",mr)-1)),l,LEFT(A2,FIND("_",A2)-1),SUBSTITUTE(TEXTJOIN(", ",,l,FILTER(f,f<>l)),","," &",ROWS(f)-1))
Thank you so much! It looks exactly like I wanted. But do you think there's something wrong with my excel? I tried to copy paste the formula but it gives me an error.
 

Attachments

  • Screenshot 2022-06-17 105219.png
    Screenshot 2022-06-17 105219.png
    29.2 KB · Views: 8
Upvote 0
Do you normally use commas as a separator in formulae, or do you normally use semi-colons?
 
Upvote 0
Ok, what if you copy the whole mini-sheet (using the copy icon) & paste it into a blank sheet?

Copy icon.png
 
Upvote 0
Ok, what if you copy the whole mini-sheet (using the copy icon) & paste it into a blank sheet?

View attachment 67307
I think I know why it's giving me an error. My corporate Excel doesn't recognize the LET Function. So I tried it on my personal PC and it works.
Is there any other method I could use other than the LET function? Does VBA or other excel features can do the same?
Also another thing that I found with your formula is that it will only work in certain range of cell, if the cell is empty then it gives #VALUE! error if I try to increase the range ($A$2:$A$100). Since my number of rows could be change from time to time, I would need this in automaton just like my other formulas.
But it is okay if not possible. Thank you so much for all the help and the answers.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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