Anyway to optimize the formula

arno911

New Member
Joined
May 2, 2023
Messages
2
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
  2. MacOS
Goal: to extract text between {{}} from a block of text.

Input: Lorem ipsum dolor sit amet, {{consectetur}} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in {{reprehenderit}} in voluptate velit esse cillum dolore eu fugiat {{nulla}} pariatur. {{Excepteur}} sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id {{est}} laborum.
Excel Formula:
=REPLACE(LEFT(C4,FIND("}}",C4&"}}")-1),1,FIND("{{",C4&"{{"),"")&REPLACE(LEFT(C4,FIND("#",SUBSTITUTE(C4&REPT("}}",2),"}}","#",2))-1),1,FIND("#",SUBSTITUTE(C4&REPT("{{",2),"{{","#",2)),"")&REPLACE(LEFT(C4,FIND("#",SUBSTITUTE(C4&REPT("}}",3),"}}","#",3))-1),1,FIND("#",SUBSTITUTE(C4&REPT("{{",3),"{{","#",3)),"")&REPLACE(LEFT(C4,FIND("#",SUBSTITUTE(C4&REPT("}}",4),"}}","#",4))-1),1,FIND("#",SUBSTITUTE(C4&REPT("{{",4),"{{","#",4)),"")&REPLACE(LEFT(C4,FIND("#",SUBSTITUTE(C4&REPT("}}",5),"}}","#",5))-1),1,FIND("#",SUBSTITUTE(C4&REPT("{{",5),"{{","#",5)),"")
Output: {consectetur{reprehenderit{nulla{Excepteur{est

Can this formula be also made to accommodate infinite items?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
For 365 how about
Excel Formula:
="{"&TEXTJOIN("{",,INDEX(TEXTSPLIT(C4,"{{","}}",1,,""),,2))
 
Upvote 0
Solution
wow. i have been losing my mind over this for so long. thank you so much Fluff
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

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