How to split inconsistent text into 4columns

mart_mrexcel

Active Member
Joined
Aug 23, 2008
Messages
310
Office Version
  1. 365
Platform
  1. Windows
I have an inconsistent Joined text and i want to split them into 4 columns (column C,D,E,F) as per the table below (expected output). The sequence of the joined text are all the same e.g. all currency are placed in the left and the grade is placed at the end and so on. Appreciate if someone can assist me to split it using TEXTSPLIT() OR LEFT, MID , RIGHT functions.


ABCDEF
1Joined TextCurrencyCompanyGroupGrade
2
EURPLNG (NIC) _Quezon (1000)NationalsG8
EURPLNG (NIC) _Quezon (1000)NationalsG8
3USDPatio-Company (4115)Eastern ExpatriatesG6USDPatio-Company (4115)
Eastern Expatriates
G6
4USDTank (NIC) _HQ H.O. Eastern ExpatriatesG12USDTank (NIC) _HQ H.O.Eastern ExpatriatesG12
5EURPLNG (NIC) _Quezon (1000)Non NationalsEURPLNG (NIC) _Quezon (1000)Non Nationals
6KRWG10KRWG10
7USDKiosk/FT (8300) WesternG9USDKiosk/FT (8300)WesternG9
8SAR NationalsG18SARNationalsG18
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assuming that Currency is always present, how about?:

SplitInconsistentText.xlsx
ABCDEFGHIJKLM
1Joined TextCurrencyCompanyGroupGradeCurrencyCompanyGroupGradeGroups
2EURPLNG (NIC) _Quezon (1000)NationalsG8EURPLNG (NIC) _Quezon (1000)NationalsG8EURPLNG (NIC) _Quezon (1000)NationalsG8Nationals
3USDPatio-Company (4115)Eastern ExpatriatesG6USDPatio-Company (4115)Eastern ExpatriatesG6USDPatio-Company (4115)Eastern ExpatriatesG6Non Nationals
4USDTank (NIC) _HQ H.O. Eastern ExpatriatesG12USDTank (NIC) _HQ H.O.Eastern ExpatriatesG12USDTank (NIC) _HQ H.O. Eastern ExpatriatesG12Eastern Expatriates
5EURPLNG (NIC) _Quezon (1000)Non NationalsEURPLNG (NIC) _Quezon (1000)Non NationalsEURPLNG (NIC) _Quezon (1000)Non Nationals Western
6KRWG10KRWG10KRW  G10
7USDKiosk/FT (8300) WesternG9USDKiosk/FT (8300)WesternG9USDKiosk/FT (8300) WesternG9
8SAR NationalsG18SARNationalsG18SAR NationalsG18
9EURPLNG (NIC) _Quezon (1000)NationalsG8EURPLNG (NIC) _Quezon (1000)NationalsG8EURPLNG (NIC) _Quezon (1000)NationalsG8
10USDEastern ExpatriatesG6USDEastern ExpatriatesG6USD Eastern ExpatriatesG6
11USDTank (NIC) _HQ H.O.G12USDTank (NIC) _HQ H.O.G12USDTank (NIC) _HQ H.O. G12
12EURPLNG (NIC) _Quezon (1000)NationalsEURPLNG (NIC) _Quezon (1000)NationalsEURPLNG (NIC) _Quezon (1000)Nationals 
13KRWG10KRWG10KRW  G10
14USDKiosk/FT (8300)USDKiosk/FT (8300)USDKiosk/FT (8300)  
15SARNationalsSARNationalsSAR Nationals 
16EUREUREUR   
Sheet1
Cell Formulas
RangeFormula
H2:H16H2=LEFT(A2, 3)
I2:I16I2=TEXTBEFORE(TEXTAFTER(A2, H2)&"|@", J2&K2&"|@")
J2:J16J2=LET(d, IFERROR(INDEX($M$2:$M$5, MAX(IFERROR(SEARCH($M$2:$M$5, A2)>0,0)*SEQUENCE(4))),""), IF(ROWS(d)>1, "", d))
K2:K16K2=LET(d,RIGHT(A2,3), IF(IFERROR(FIND("G",d),0), "G"&TEXTAFTER(d, "G"),"") )
A9:A16A9=CONCAT(C9:F9)
 
Upvote 0
Only if REGEXTRACT function can be used in your Excel. (Available in Microsoft 365 Insiders)
Book1.xlsm
ABCDEF
1Joined TextCurrencyCompanyGroupGrade
2EURPLNG (NIC) _Quezon (1000)NationalsG8EURPLNG (NIC) _Quezon (1000)NationalsG8
3USDPatio-Company (4115)Eastern ExpatriatesG6USDPatio-Company (4115)Eastern ExpatriatesG6
4USDTank (NIC) _HQ H.O. Eastern ExpatriatesG12USDTank (NIC) _HQ H.O. Eastern ExpatriatesG12
5EURPLNG (NIC) _Quezon (1000)Non NationalsEURPLNG (NIC) _Quezon (1000)Non Nationals
6KRWG10KRWG10
7USDKiosk/FT (8300) WesternG9USDKiosk/FT (8300) WesternG9
8SAR NationalsG18SAR NationalsG18
Sheet1
Cell Formulas
RangeFormula
C2:F8C2=IFERROR(REGEXEXTRACT(A2,"^([A-Z]{3})(.*?)([A-Z][a-z]+(?: [A-Z][a-z]+)*)*(G\d+)*$",2),"")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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