Split text in a cell into multiple columns

excelvbanoob420

New Member
Joined
Oct 5, 2022
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to solve a difficult problem of splitting data in a cell into multiple columns based on the number of items in that cell. Below is the sample data and I would like to split the data in Column3, Column4 and Column5 into multiple columns where each column contains an individual values based on text string 'FJ-SJ'. Any text with 'FJ-RJ' should be ignored in the split. This problem can better be understood by looking at the input and desired output shown below.

Input:

Column1Column2Column3Column4Column5
FJ-SJ-1111-1111Randomtext1FJ-SJ-0000-0101
FJ-RJ-0000-0010
FJ-SJ-0000-0102
FJ-SJ-0000-0103
FJ-SJ-0000-0104
FJ-SJ-0000-1111
FJ-RJ-0000-1111
FJ-SJ-1111-1112Randomtext2FJ-SJ-0000-0112
FJ-SJ-0000-0113
FJ-SJ-0000-0114
FJ-RJ-0000-0011
FJ-SJ-0000-0106
FJ-SJ-0000-0105
FJ-SJ-0000-1112
FJ-SJ-0000-1113
FJ-SJ-0000-1114
FJ-SJ-1111-1113Randomtext3FJ-RJ-0000-0011
FJ-RJ-0000-0012
FJ-SJ-0000-0115
FJ-SJ-0000-0116
FJ-SJ-0000-0117
FJ-RJ-0000-0011
FJ-RJ-0000-0012
FJ-SJ-0000-0107
FJ-SJ-0000-0108
FJ-RJ-0000-1112
FJ-SJ-0000-1115
FJ-SJ-0000-1116
FJ-SJ-0000-1117
FJ-SJ-1111-1114Randomtext4FJ-SJ-0000-0118
FJ-SJ-0000-0119
FJ-SJ-0000-0109FJ-SJ-0000-1119

Output:
Column1Column2Column3Column4Column5
FJ-SJ-1111-1111Randomtext1FJ-SJ-0000-0101
FJ-RJ-0000-0010
FJ-SJ-0000-0101FJ-SJ-0000-0102
FJ-SJ-0000-0103
FJ-SJ-0000-0104
FJ-SJ-0000-0102FJ-SJ-0000-0103FJ-SJ-0000-0104FJ-SJ-0000-1111
FJ-RJ-0000-1111
FJ-SJ-0000-1111
FJ-SJ-1111-1112Randomtext2FJ-SJ-0000-0112
FJ-SJ-0000-0113
FJ-SJ-0000-0114
FJ-SJ-0000-0112FJ-SJ-0000-0113FJ-SJ-0000-0114FJ-RJ-0000-0011
FJ-SJ-0000-0106
FJ-SJ-0000-0105
FJ-SJ-0000-0106FJ-SJ-0000-0105FJ-SJ-0000-1112
FJ-SJ-0000-1113
FJ-SJ-0000-1114
FJ-SJ-0000-1112FJ-SJ-0000-1113FJ-SJ-0000-1114
FJ-SJ-1111-1113Randomtext3FJ-RJ-0000-0011
FJ-RJ-0000-0012
FJ-SJ-0000-0115
FJ-SJ-0000-0116
FJ-SJ-0000-0117
FJ-SJ-0000-0115FJ-SJ-0000-0116FJ-SJ-0000-0117FJ-RJ-0000-0011
FJ-RJ-0000-0012
FJ-SJ-0000-0107
FJ-SJ-0000-0108
FJ-SJ-0000-0107FJ-SJ-0000-0108FJ-RJ-0000-1112
FJ-SJ-0000-1115
FJ-SJ-0000-1116
FJ-SJ-0000-1117
FJ-SJ-0000-1115FJ-SJ-0000-1116FJ-SJ-0000-1117
FJ-SJ-1111-1114Randomtext4FJ-SJ-0000-0118
FJ-SJ-0000-0119
FJ-SJ-0000-0118FJ-SJ-0000-0119FJ-SJ-0000-0109FJ-SJ-0000-0109FJ-SJ-0000-1119FJ-SJ-0000-1119


Any help i can get to solve this dynamic column creation problem will be highly appreciated.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Excel Formula:
=FILTER(TEXTSPLIT(C2,CHAR(10)),LEFT(TEXTSPLIT(C2,CHAR(10)),5)<>"FJ-RJ")
 
Upvote 0
This gave me every item in the original cell separately (provided it doesn't start with "FJ-RJ"). And no VBA was used.
 
Upvote 0
I use textsplit to split up the string whenever it finds a CHAR(10), which is the line break. But if it's not working use the CODE function on every character in the string to find what code is being used that you want to split by.
Excel Formula:
=CODE(MID(A1,SEQUENCE(LEN(A1)),1))

That should give you what CHAR you are looking for to split by.
 
Upvote 0
I use textsplit to split up the string whenever it finds a CHAR(10), which is the line break. But if it's not working use the CODE function on every character in the string to find what code is being used that you want to split by.
Excel Formula:
=CODE(MID(A1,SEQUENCE(LEN(A1)),1))

That should give you what CHAR you are looking for to split by.
ok that works for one column. However if you look at my the output i provided in my original post, I have multiple columns that i want to split. Is there a way I can do this recursively for each column?
 
Upvote 0
@excelvbanoob420
In case the problem was not solved using the formula provided by JamesCanale, then it would be better if you share a sample workbook with the real data and cell formats.
You need to use a fileshare service; Microsoft OneDrive, Google Drive, Dropbox and many other companies offer this option.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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