Okoth
Board Regular
- Joined
- Sep 10, 2009
- Messages
- 106
- Office Version
- 2019
- Platform
- Windows
I want to find a string in one cell and add text before and after the first occurrence of that string. An example is easier to explain. I want to add <strong> before time and </strong> after time. What is important is that it only happens with the first occurrence of the word time. A1 is the original text and B1 is the result of the formula.
To get <strong> before the first "time" wasn't hard. I managed with:
but how do I get </strong> after the first "time" in A1? I want to do this with a formula not VBA.
A | B | |
1 | This is the first time the string occurs and this is the second time it shows up. | This is the first<strong>time</strong> the string occurs and this is the second time it shows up. |
To get <strong> before the first "time" wasn't hard. I managed with:
Excel Formula:
=MID(A1;1;FIND("time";A1)-1)&"<strong>"&MID(A1;FIND("time";A1);9999)
but how do I get </strong> after the first "time" in A1? I want to do this with a formula not VBA.
Last edited: