Help me with an excel formula to convert a string to another

mechrobin

New Member
Joined
Nov 22, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I want to convert following string
P4-128-HS-29039-128299-3-SP01​
to
4300-SP-XH-DL-128299-128-HS-29039-03-SP01-Q​


Please note length of the first string may vary for example
U4-126-ETT-11024-126101-10-SP01​
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
ORGINAL STRING​
CHANGE TO​
P4-128-HS-29039-128299-3-SP01​
4300-SP-XH-DL-128299-128-HS-29039-03-SP01-Q​
U4-126-ETT-11024-126101-10-SP01​
4300-SP-XH-DL-126101-126-ETT-11024-10-SP01-Q​
 
Upvote 0
Hi, perhaps this will work for you.

Book1
AB
1ORGINAL STRINGCHANGE TO
2P4-128-HS-29039-128299-3-SP014300-SP-XH-DL-128299-128-HS-29039-03-SP01-Q
3U4-126-ETT-11024-126101-10-SP014300-SP-XH-DL-126101-126-ETT-11024-10-SP01-Q
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=TEXTJOIN("-",0,"4300-SP-XH-DL",CHOOSECOLS(TEXT(TEXTSPLIT(A2,"-"),"00"),{5,2,3,4,6,7}),"Q")
Hi @FormR thanks for your help. But it's not working for some text. For eg.
P4-131-DI-00001-131002-4-SP034300-SP-XH-DL-131002-131-DI-01-04-SP03-Q.pdf

In this result should be
4300-SP-XH-DL-131002-131-DI-00001-04-SP03-Q.pdf
 
Upvote 0
But it's not working for some text. For eg.
Hi, it doesn't help only having a couple of examples and not having any explanation of the translation. But you can give this a try:

Book2
AB
1ORGINAL STRINGCHANGE TO
2P4-128-HS-29039-128299-3-SP014300-SP-XH-DL-128299-128-HS-29039-03-SP01-Q.pdf
3U4-126-ETT-11024-126101-10-SP014300-SP-XH-DL-126101-126-ETT-11024-10-SP01-Q.pdf
4P4-131-DI-00001-131002-4-SP034300-SP-XH-DL-131002-131-DI-00001-04-SP03-Q.pdf
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=LET(CC,TEXTSPLIT(A2,"-"),TEXTJOIN("-",0,"4300-SP-XH-DL",INDEX(CC,0,{5,2,3,4}),TEXT(INDEX(CC,0,6),"00"),INDEX(CC,0,7),"Q.pdf"))
 
Upvote 0
Solution
Hi, it doesn't help only having a couple of examples and not having any explanation of the translation. But you can give this a try:

Book2
AB
1ORGINAL STRINGCHANGE TO
2P4-128-HS-29039-128299-3-SP014300-SP-XH-DL-128299-128-HS-29039-03-SP01-Q.pdf
3U4-126-ETT-11024-126101-10-SP014300-SP-XH-DL-126101-126-ETT-11024-10-SP01-Q.pdf
4P4-131-DI-00001-131002-4-SP034300-SP-XH-DL-131002-131-DI-00001-04-SP03-Q.pdf
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=LET(CC,TEXTSPLIT(A2,"-"),TEXTJOIN("-",0,"4300-SP-XH-DL",INDEX(CC,0,{5,2,3,4}),TEXT(INDEX(CC,0,6),"00"),INDEX(CC,0,7),"Q.pdf"))
Thank you so much. It's worked
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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