Separating a part of the string from it's three first characters

apace

New Member
Joined
Jun 28, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to separate a string from it's three initial characters.

Example:
100345-123-2455100345-123-2455
345-123-544444345123-544444

I have figured out, with help, how to separate the three characters, using the function: =IF(COUNTIF($J$2:$J$100;LEFT(A2;3)&"*")>0;LEFT(A2;3);"Missing").

I am now struggling with separating the other part of the string. Sometimes the string occurs with a dash after the first three character, sometimes without it, and I am confused as to how to write a function that would understand that.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Second portion can be extracted by introducing a test for 4th character like below:
Excel Formula:
=MID(A2,IF(MID(A2,4,1)="-",5,4),LEN(A2))
 
Upvote 0
Second portion can be extracted by introducing a test for 4th character like below:
Excel Formula:
=MID(A2,IF(MID(A2,4,1)="-",5,4),LEN(A2))
oh wow, that's really smart, didn't even think about that. I initially just separated by creating a function that recognized the first dash. Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,017
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