Find enter stroke and add text

Excel_Blonde

New Member
Joined
Aug 8, 2018
Messages
44
Hi There,

I'm looking for a VBA script (or formula) to find an enter stroke and add text.

E.g

Sample Text
123
abc

Def
GHI

To appear:

Sample Text\par
123\par
abc\par
\par
Def\par
GHI\par

Apologies if this question has previously been asked and answered, I cant find anything on the forums but may be using the wrong words in my searches.
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,006
Office Version
  1. 365
Platform
  1. Windows
Try Ctrl H
Find what > Ctrl J
replace > \par
Make sure that match cell contents is unchecked
Replace all
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
Assuming that your data starts in A1 put the following formula in B1

=A1&"\par"

Copy the formula down
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,385
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Assuming you mean the sample data shown is all in a Single cell, separated by linefeed, formula option:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Sample Text
123
abc

Def
GHI</td><td style=";">Sample Text\par
123\par
abc\par
\par
Def\par
GHI\par</td></tr></tbody></table><p style="width:6.4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet637</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B1</th><td style="text-align:left">=SUBSTITUTE(<font color="Blue">A1,CHAR(<font color="Red">10</font>),"\par"&CHAR(<font color="Red">10</font>)</font>)&"\par"</td></tr></tbody></table></td></tr></table><br />
 
Last edited:

Excel_Blonde

New Member
Joined
Aug 8, 2018
Messages
44
Hi,

Assuming you mean the sample data shown is all in a Single cell, separated by linefeed, formula option:

AB
1Sample Text
123
abc

Def
GHI
Sample Text\par
123\par
abc\par
\par
Def\par
GHI\par

<tbody>
</tbody>
Sheet637

Worksheet Formulas
CellFormula
B1=SUBSTITUTE(A1,CHAR(10),"\par"&CHAR(10))&"\par"

<tbody>
</tbody>

<tbody>
</tbody>


This works perfectly. Thank you all for your suggestions, this has saved me hours if not days of manual input.
 
Last edited:

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,385
Office Version
  1. 2016
Platform
  1. Windows
You're welcome, thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,669
Messages
5,597,474
Members
414,145
Latest member
lonnie451

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
Top