Extract a word in a string based on a ","

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
769
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I have been looking for a calculation to help me pull a word/phrase from a string based on ",".
I don't want to auto delimit these when loading as there is an amount of data in the string I don't need, but the info is set out the same for each line.

I want to pull data between the 2nd & 3rd , but I will then want to pull from between others as I progress, but for the life of me I cant get anything to pull through.

I am currently using the code below, apologies if this is a simple one but it is driving me nuts

Code:
=TRIM(LEFT(SUBSTITUTE(MID(TabName[Column1],FIND(",",SUBSTITUTE(TabName[Column1],":",",",2))+1,LEN(TabName[Column1])),",",REPT(" ",LEN(TabName[Column1]))),LEN(TabName[Column1])))

String is
CS:20210412000000514,00001535020000034111,13835049,XXXX,Area,Brand,MODEL,,,,BoughtDate,,;

thanks in advance
Gavin
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Good morning,

I have been looking for a calculation to help me pull a word/phrase from a string based on ",".
I don't want to auto delimit these when loading as there is an amount of data in the string I don't need, but the info is set out the same for each line.

I want to pull data between the 2nd & 3rd , but I will then want to pull from between others as I progress, but for the life of me I cant get anything to pull through.

I am currently using the code below, apologies if this is a simple one but it is driving me nuts

Code:
=TRIM(LEFT(SUBSTITUTE(MID(TabName[Column1],FIND(",",SUBSTITUTE(TabName[Column1],":",",",2))+1,LEN(TabName[Column1])),",",REPT(" ",LEN(TabName[Column1]))),LEN(TabName[Column1])))

String is
CS:20210412000000514,00001535020000034111,13835049,XXXX,Area,Brand,MODEL,,,,BoughtDate,,;

thanks in advance
Gavin

do you want extract text between 2nd and 3rd "," if I am correct use below
assuming your string starts from A2

Excel Formula:
=TRIM(LEFT(SUBSTITUTE(MID(SUBSTITUTE(A2,",","x",2),FIND("x",SUBSTITUTE(A2,",","x",2))+1,99),",",REPT(" ",99)),99))
 
Upvote 0
Solution
Thanks for this. I am using PowerPivot.
What does the "x" stand for?
 
Upvote 0
@A Durfani, whats the best way to see if a word appears in the string. ie if "Mondeo" appears can I get my column Model to show Mondeo for that line of data
 
Upvote 0
I think you should start a new thread for that with sample data
 
Upvote 0

Forum statistics

Threads
1,223,697
Messages
6,173,896
Members
452,536
Latest member
Chiz511

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