Replace 2 or more spaces with text

goble

New Member
Joined
Oct 7, 2010
Messages
46
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I have :

SerialNameCompositionData for HTML
1Destadine SyrupEach ml contains:
Desratadine BP …….. 0.5
In a flavoured syrup base
FORMULA (Thanks to @Fluff)
="<tr><td>"&TEXTJOIN("</td><td>",,SUBSTITUTE(LEFT(A2:C2,LEN(A2:C2)-1),CHAR(10),"<br>"))&"</td></tr"

Results =
<tr><td>Destadine Syrup</td><td>Each ml contains:<br>Desratadine BP …….. 0.5 mg<br>In a flavoured syrup bas</td></tr
2Terbinafine Each uncoated tablet contains: Terbinafine Hydrochloride BP eq. to Terbinafine ......................... 250 mg

I would like data in C3 to look like C2 i.e. C3 should have it's data on each line instead of spaces (yes these are spaces since I can get rid of them using 'TRIM').

I was thinking of a formula that replaces 2 or more space with <br>. At the end of the day (whether data in column C are on different lines or separated by spaces) my final results should be like column D.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Select D2 and move the cursor to the right bottom corner of the cell until you see a cross, then left-click and drag it down to D3.
If the text in C3 is separated into lines properly (now not) you should get the value you want in D3 with <br>, if this is what you mean.
 
Upvote 0
Hello and thanks,

Drag it down will make the same as CTRL-D in D3, no ? Anyway I get the same result as CTRL-D.

Also, I saw that the spaces went away after I posted the above.
Cell C3 should read :
"2 spaces here without quotes"Each uncoated tablet contains:"48 spaces here without quotes"Terbinafine Hydrochloride"36 spaces here without quotes"BP eq. to Terbinafine ......................... 250 mg"
 
Upvote 0
Hello,

am posting again to clarify the above (and since I haven't been able to sort this out).

I would like to change the cell from:
12345(4 spaces in between)abcd(12 spaces in between)xyz(5 spaces in between)789
to:
12345<br>abcd<br>xyz<br>789

So change 2 or more spaces in Cell with <br>
 
Upvote 0
I would like to change the cell from:
12345(4 spaces in between)abcd(12 spaces in between)xyz(5 spaces in between)789
to:
12345<br>abcd<br>xyz<br>789

Hi - something like this maybe:

Book1
AB
112345 abcd xyz 78912345<br>abcd<br>xyz<br>789
Sheet1
Cell Formulas
RangeFormula
B1B1=SUBSTITUTE(TRIM(A1)," ","<br>")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,465
Messages
6,124,982
Members
449,201
Latest member
Lunzwe73

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