Split text into columns with different delimiters

probexcel

New Member
Joined
Nov 16, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I am having a little bit of trouble trying to come with a solution for my problem, I have a table where one of the columns has texts like:
This is one text 2019
This is one text 2020
This is one product 2018 (6bl
This is one product 2020 (6bl)
This is a pain 2020 (6bl)
This is a pain 2021 (6bl)
This is hard (6bl) 2017
This is hard (6bl) 2018
This is lack of creativity (12x6) 2014
This is lack of creativity (12x6) 2015
This is the last example (With explanation) and more text 2020
This is the last example (With explanation) and more text 2022

What I need to do is to compare the text part and the (6bl) part. and if everything is the same but the year is different, in the new column I need to flag them. My problem is, I couldn't find a good way to extract the year out of this string, and also, if you realize in the text that is in red, some of the parenthesis are not being closed. The table is huge, so I just would like some idea on how to tackle this project.

My final output could be something like:

This is one text2019
This is one text2020
This is one product20186bl
This is one product20206bl
This is a pain20206bl
This is a pain20216bl
This is hard20176bl
This is hard20186bl
This is lack of creativity201412x6
This is lack of creativity201512x6
This is the last example (With explanation) and more text2020
This is the last example (With explanation) and more text2022

Is there any way to achieve that through formulas or VBA?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
With that sample, how about
Fluff.xlsm
ABC
1
2This is one text 20192019 
3This is one text 20202020 
4This is one product 2018 (6bl20186bl
5This is one product 2020 (6bl)20206bl
6This is a pain 2020 (6bl)20206bl
7This is a pain 2021 (6bl)20216bl
8This is hard (6bl) 201720176bl
9This is hard (6bl) 201820186bl
10This is lack of creativity (12x6) 2014201412x6
11This is lack of creativity (12x6) 2015201512x6
12This is the last example (With explanation) and (6bl) text 202020206bl
13This is the last example (With explanation) and more text 20222022 
Lists
Cell Formulas
RangeFormula
B2:B13B2=FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[.=number()]")
C2:C13C2=IFERROR(SUBSTITUTE(SUBSTITUTE(FILTERXML("<k><m>"&SUBSTITUTE(A2&")"," ","</m><m>")&"</m></k>","//m[contains(.,'(') and contains(.,')')]"),")",""),"(",""),"")
 
Upvote 0
With that sample, how about
Fluff.xlsm
ABC
1
2This is one text 20192019 
3This is one text 20202020 
4This is one product 2018 (6bl20186bl
5This is one product 2020 (6bl)20206bl
6This is a pain 2020 (6bl)20206bl
7This is a pain 2021 (6bl)20216bl
8This is hard (6bl) 201720176bl
9This is hard (6bl) 201820186bl
10This is lack of creativity (12x6) 2014201412x6
11This is lack of creativity (12x6) 2015201512x6
12This is the last example (With explanation) and (6bl) text 202020206bl
13This is the last example (With explanation) and more text 20222022 
Lists
Cell Formulas
RangeFormula
B2:B13B2=FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[.=number()]")
C2:C13C2=IFERROR(SUBSTITUTE(SUBSTITUTE(FILTERXML("<k><m>"&SUBSTITUTE(A2&")"," ","</m><m>")&"</m></k>","//m[contains(.,'(') and contains(.,')')]"),")",""),"(",""),"")
Ohh my gosh, thank you so much. That's basically what I needed. One question, for the formula that extracts the year, cell B2, I have one row that is like that:
This is a text number 2 2020

This is giving me a SPILL error because the spill range isn't blank, how can I fix that to either return only the number with four digits, or to always get the second number? Because I just checked, and every line that has a number like that, the year comes after it.
 
Upvote 0
Will there only ever be one 4 digit number?
 
Upvote 0
Ok, how about
Excel Formula:
=FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[.=number() and string-length()=4]")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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