Remove text appearing between two characters - multiple instances - Excel -
in microsoft excel file, have text in rows appears this:
1. rc8 {[%emt 0:00:05]} rxc8 {[%emt 0:00:01]} 2. rxc8 {[%emt 0:00:01]} qxc8 {} 3. qe7#  1-0 i need remove text appearing within flower brackets { , }, including brackets themselves. 
in above example, there 3 instances of such flower brackets. rows might have more that.
i tried =mid(left(a2,find("}",a2)-1),find("{",a2)+1,len(a2)) 
this outputs to: {[%emt 0:00:05]}. see first instance of text between flower brackets.
and if use within substitute this: =substitute(a2,mid(left(a2,find("}",a2)),find("{",a2),len(a2)),"")
i output this:
1. rc8  rxc8 {[%emt 0:00:01]} 2. rxc8 {[%emt 0:00:01]} qxc8 {} 3. qe7#  1-0 
if have noticed, 1 instance removed. how make work instances? thanks.
it not easy without vba, there still way.
either (as suggested yu_ominae) use formula , auto-fill it:
=iferror(substitute(a2,mid(left(a2,find("}",a2)),find("{",a2),len(a2)),""),a2) another way iterative calculations (go options -> formulas -> check "enable iterative calculations" button)
 in 1 cell, need 1 helper-cell (for example use c1) , use formula in b2 , auto-fill down:
=if($c$1,a2,iferror(substitute(b2,mid(left(b2,find("}",b2)),find("{",b2),len(b2)),""),b2)) put "1" in c1 , formulas in b:b show values of a:a. go c1 , hit del-key several times (you see "{}"-parts disappearing) till looks want it.
edit: via vba without regex can put module:
public function delbrc(byval str string) string   while instr(str, "{") > 0 , instr(str, "}") > instr(str, "{")     str = left(str, instr(str, "{") - 1) & mid(str, instr(str, "}") + 1)   wend   delbrc = trim(str) end function and in worksheet directly use:
=delbrc(a2) if still have questions, ask ;)
Comments
Post a Comment