Splitting large sting of data

DPChristman

Board Regular
Joined
Sep 4, 2012
Messages
178
Office Version
  1. 365
Platform
  1. Windows
I have a large string of data (25 characters), that basically consists of
5 characters for the location number
2 characters for the terminal number
4 characters for the transaction number
8 digits for the date
6 digits for the time
I basically want to separate the date into groups using special characters.
Example:
1234501123420240214144322
Would become
12345-01-1234-2024/02/14-14:4322
I know there is a way to do this, but I cannot think of it.

Any ideas?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Maybe this to get you started:
Book1
AB
1123450112342024021414432212345-01-1234-2024/02/14-14:4322
Sheet1
Cell Formulas
RangeFormula
B1B1=TEXTJOIN("-",,LEFT(A1,5),MID(A1,6,2),MID(A1,8,4),TEXTJOIN("/",,MID(A1,12,4),MID(A1,16,2),MID(A1,18,2)),MID(A1,20,2))&":"&RIGHT(A1,4)
 
Upvote 0
Perfect, Thanks

Quick quest - What do I need to include to get the end (14:4322) to display as 14:43:22, or to remove the 22 completely.

Thanks again
 
Upvote 0
Perfect, Thanks

Quick quest - What do I need to include to get the end (14:4322) to display as 14:43:22, or to remove the 22 completely.

Thanks again
Cell Formulas
RangeFormula
B1B1=TEXTJOIN("-",,LEFT(A1,5),MID(A1,6,2),MID(A1,8,4),TEXTJOIN("/",,MID(A1,12,4),MID(A1,16,2),MID(A1,18,2)),MID(A1,20,2))&":"&LEFT(RIGHT(A1,4),2)
B2B2=TEXTJOIN("-",,LEFT(A1,5),MID(A1,6,2),MID(A1,8,4),TEXTJOIN("/",,MID(A1,12,4),MID(A1,16,2),MID(A1,18,2)),MID(A1,20,2))&":"&LEFT(RIGHT(A1,4),2)&":"&RIGHT(A1,2)
 
Upvote 0
Another option which may be easier to read:
Excel Formula:
=TEXT(LEFT(A1,11),"#####-##-####-")&TEXT(MID(A1,12,8),"####\/##\/##-")&TEXT(RIGHT(A1,6),"##\:##\:##")
 
Upvote 0
Solution
Cell Formulas
RangeFormula
B1B1=TEXTJOIN("-",,LEFT(A1,5),MID(A1,6,2),MID(A1,8,4),TEXTJOIN("/",,MID(A1,12,4),MID(A1,16,2),MID(A1,18,2)),MID(A1,20,2))&":"&LEFT(RIGHT(A1,4),2)
B2B2=TEXTJOIN("-",,LEFT(A1,5),MID(A1,6,2),MID(A1,8,4),TEXTJOIN("/",,MID(A1,12,4),MID(A1,16,2),MID(A1,18,2)),MID(A1,20,2))&":"&LEFT(RIGHT(A1,4),2)&":"&RIGHT(A1,2)
Thanks
 
Upvote 0
Yeah that works perfectly. Thanks!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers.

BTW, you could do it in 2 parts rather than 3 by combining the date & time parts together
Also, by using "0" rather than "#" as the place-holders, if it is possible that a "location number" could have one or more leading zeros, this formula would retain those zeros whereas the earlier formula would drop them leaving you with a less than 5 character location number. See row 2 below.

24 02 17.xlsm
ABC
1Peterdreid
2123450112342024021414432212345-01-1234-2024/02/14-14:43:2212345-01-1234-2024/02/14-14:43:22
3000450112342024021414432200045-01-1234-2024/02/14-14:43:2245-01-1234-2024/02/14-14:43:22
Reformat
Cell Formulas
RangeFormula
B2:B3B2=TEXT(LEFT(A2,11),"00000-00-0000-")&TEXT(RIGHT(A2,14),"0000\/00\/00-00\:00\:00")
C2:C3C2=TEXT(LEFT(A2,11),"#####-##-####-")&TEXT(MID(A2,12,8),"####\/##\/##-")&TEXT(RIGHT(A2,6),"##\:##\:##")
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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