Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

Extract text between two nth occurrences of a character from a cell in Excel

I have a cell in Excel with text as follows

text1 > text2 > text3 > text4 > text5 > text6

I need to find a rule to extract the some of the text and put it in another cell for example like this (the order may vary):

text6 text3 text5

I tried different solutions but they don't really work as expected:

=TRIM(MID(D6,FIND("#",SUBSTITUTE(D6,">","#",2))+1,255))

=REPLACE(D7,1,FIND("^^",SUBSTITUTE(D7,">","^^",8))+1,"")

=RIGHT(D4,LEN(D4)-SEARCH("#",SUBSTITUTE(D4,">","#",LEN(D4)-LEN(SUBSTITUTE(D4,">","")))))&" "&MID(D4, FIND(CHAR(1),SUBSTITUTE(D4,">",CHAR(1),3))+2, FIND(CHAR(1),SUBSTITUTE(D4,">",CHAR(1),3)) - FIND(CHAR(1),SUBSTITUTE(D4,">",CHAR(1),2))-11)

Can you help me with that? Thanks

EDIT: Found the solution! This rule is working fine for me. If you change the value of X you change the number of the occurrencies:

=SUBSTITUTE(MID(SUBSTITUTE(">" & D5&REPT(" ",6),">",REPT(",",255)),X*255,255),",","")
question from:https://stackoverflow.com/questions/65906506/extract-text-between-two-nth-occurrences-of-a-character-from-a-cell-in-excel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...