Pulling data from specific Feild

pratheesh1983

Board Regular
Joined
Aug 13, 2015
Messages
55
Office Version
  1. 365
Platform
  1. Windows
I'm looking for a formula in Excel that can extract field content from a field tag that is specified in a cell that is mentioned next to the text. I have provided a message sample that would explain the requirement in more detail.

The formula that I'm using is giving me a blank value in some cells; this may be because of a line break in the respective field from which the data needs to be extracted. I would appreciate it if someone could help me fix this issue.



ABC (Formula to be added in this column to extract the data based on field ID mentioned in B column.)
TEXTFEILD FEILD CONTENT
🇵🇰
AMAN SOLUTIONS LTD
110, MG ROAD
BANGALORE 03
INDIA
:YU1:689009882
XYZ OPS
:CN2:
GEORGE THOMAS
CN2GEORGE THOMAS
🇵🇰
ABC LTD
SILICON, MG ROAD
BANGALORE 03
INDIA
:YU1:
BOLONO
:CN2:
MARTIN
:CN1: JACOB ALEX
:PB3: JOSE ELEC
CN1
JACOB ALEX

Formula Used: =TRIM(LEFT(SUBSTITUTE(REPLACE($A2,1,SEARCH($B2,$A2)+LEN($B2),""),CHAR(10),REPT(" ",100)),100))
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
There are probably a lot of ways to get the result you want. One way:
tmp.xlsm
ABC
1TEXTFIELDFIELD CONTENT
2🇵🇰 AMAN SOLUTIONS LTD 110, MG ROAD BANGALORE 03 INDIA :YU1:689009882 XYZ OPS :CN2: GEORGE THOMASCN2 GEORGE THOMAS
3🇵🇰 ABC LTD SILICON, MG ROAD BANGALORE 03 INDIA :YU1: BOLONO :CN2: MARTIN :CN1: JACOB ALEX :PB3: JOSE ELECCN1JACOB ALEX
4🇵🇰 AMAN SOLUTIONS LTD 110, MG ROAD BANGALORE 03 INDIA :YU1:689009882 XYZ OPS :CN2: GEORGE THOMAS :CN1: JACOB ALEX :PB3: JOSE ELECPB3JOSE ELEC
5🇵🇰 ABC LTD SILICON, MG ROAD BANGALORE 03 INDIA :YU1: BOLONO :CN2: MARTIN :CN1: JACOB ALEX :PB3: JOSE ELECXYZField 'XYZ' not found
Sheet7
Cell Formulas
RangeFormula
C2:C5C2=IFERROR(TRIM(MID(SUBSTITUTE(MID(TRIM(A2)&":",FIND(":" & B2 & ":",A2)+1,LEN(A2)),":",REPT(" ",100)),10,200)),"Field '" & B2 & "' not found")
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
There are probably a lot of ways to get the result you want. One way:
tmp.xlsm
ABC
1TEXTFIELDFIELD CONTENT
2🇵🇰 AMAN SOLUTIONS LTD 110, MG ROAD BANGALORE 03 INDIA :YU1:689009882 XYZ OPS :CN2: GEORGE THOMASCN2 GEORGE THOMAS
3🇵🇰 ABC LTD SILICON, MG ROAD BANGALORE 03 INDIA :YU1: BOLONO :CN2: MARTIN :CN1: JACOB ALEX :PB3: JOSE ELECCN1JACOB ALEX
4🇵🇰 AMAN SOLUTIONS LTD 110, MG ROAD BANGALORE 03 INDIA :YU1:689009882 XYZ OPS :CN2: GEORGE THOMAS :CN1: JACOB ALEX :PB3: JOSE ELECPB3JOSE ELEC
5🇵🇰 ABC LTD SILICON, MG ROAD BANGALORE 03 INDIA :YU1: BOLONO :CN2: MARTIN :CN1: JACOB ALEX :PB3: JOSE ELECXYZField 'XYZ' not found
Sheet7
Cell Formulas
RangeFormula
C2:C5C2=IFERROR(TRIM(MID(SUBSTITUTE(MID(TRIM(A2)&":",FIND(":" & B2 & ":",A2)+1,LEN(A2)),":",REPT(" ",100)),10,200)),"Field '" & B2 & "' not found")
Thanks!
There is a scenario where we have field tags starts with < and ends with > (instead of ":") in those case what changes we need to make in the formula.

Example:

<ABC2022>
GEORGE THOMAS
 
Upvote 0
How about
Excel Formula:
=LET(x,TEXTSPLIT(SUBSTITUTE(A2,CHAR(10),""),{":","<",">"}),IFNA(TRIM(TAKE(DROP(x,,MATCH(B2,x,0)),,1)),"No match"))
 
Upvote 0
There is a scenario where we have field tags starts with < and ends with > (instead of ":") in those case what changes we need to make in the formula.

Though perhaps not as elegant as @Fluff's solution, you could extending my earlier example this way.
Excel Formula:
=IFERROR(LET(Field,B2,Text,SUBSTITUTE(SUBSTITUTE(A2,">",":"),"<",":"),TRIM(MID(SUBSTITUTE(MID(TRIM(Text)&":",FIND(":" & Field & ":",Text)+1,LEN(Text)),":",REPT(" ",100)),10,200))),"Field '" & B3 & "' not found")
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,210
Members
449,090
Latest member
bes000

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