0

What formula can I use to extract variable length strings, where all I know is the beginning and end points of the string. So for example, I have a large list of transactions where I need to extract the text between the "*", which are different lengths and sometimes different characters. (examples below)

REMARK=TRN*1*3107979027*000000000
REMARK=TRN*1*7037/09-10-19*0000000
REMARK=TRN*1*001270017788519*0000000

Thanks!

Scott Craner
  • 23,198
  • 3
  • 23
  • 26
Kalika
  • 1

3 Answers3

0

Text to Column is a good choice, but if you want to use formula to get the result, try these formulas:

B1: =LEFT(A1,FIND("*",A1)-1) enter image description here

C1: =MID(A1,FIND("*",A1)+1,FIND("*",A1,FIND("*",A1)+1)-FIND("*",A1)-1) enter image description here

D1: =MID(A1,FIND("*",A1,FIND("*",A1)+1)+1,FIND("*",A1,FIND("*",A1,FIND("*",A1)+1)+1)-FIND("*",A1,FIND("*",A1)+1)-1) enter image description here

E1: =RIGHT(A1,LEN(A1)-FIND("*",A1,FIND("*",A1,FIND("*",A1)+1)+1)) enter image description here

Lee
  • 2,963
0

Considering the sample data, to extract text between * sign, you need to do the following:

enter image description here

How it works:

  • Put text position in cell L54 & M54.
  • Formula in Cell L55, fill it across.

    =SUBSTITUTE(MID(SUBSTITUTE("*" & $J55&REPT(" ",6),"*",REPT(",",255)),L$54*255,255),",","")
    

  • Key feature of the formula is L$54*255, formula reads it like 2*255 then 3*255, where 2 & 3 are the text position between * sign.

Adjust cell references in the formula as needed.

Rajesh Sinha
  • 9,218
  • 6
  • 17
  • 37
0

Assuming each string is similar to what you show, with 3 substrings that are between asterisks *, try in some cell:

=INDEX(TRIM(MID(SUBSTITUTE($A1,"*",REPT(" ",99)),{99,198,297},99)),COLUMNS($A:A))

And fill right two more columns. Then select the three columns and fill down as far as necessary.

Source Data

enter image description here

Results

enter image description here