Insert carriage returns at x characters

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,483
I have some cells that contain text of varying lengths.

I need to put these texts into a comment in a cell which I can perform dynamically.

When entering the comment test, the comment box is autosized but this puts all the text in 1 line of test.

Using the following text as an example - More shizzle than the other one but only works on cranes. This then is the 2nd row of info to check wordwrap.

I want to have a maximum of 25 characters per line. If the 26th character is a space then insert a carriage return at character 26 or find the last space in the first 25 characters and insert the CR here and then ignoring the 1st x characters (up to 25 characters) perform the same until all the texts has the appropriate CRs inserted.

The example text would then look as follows in the comment box -
More shizzle than the
other one but only works
on cranes. This then is
the 2nd row of info to
check wordwrap.


Open to both VBA or formula based solutions.

Thanks


 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,118
Office Version
  1. 365
Platform
  1. Windows
Book1
EF
100a bcabc
Sheet1
Cell Formulas
RangeFormula
E100E100=REPLACE(F100,2,0,CHAR(10))
 

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,483
Not sure exactly what your suggestion is doing Irobbo.

I have tried but all it does is insert a CR at character 2.
 

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,118
Office Version
  1. 365
Platform
  1. Windows
It's an example. You'll need to nest some formulas and change the position of the insertion values to get the desired result.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,141
Messages
5,628,947
Members
416,354
Latest member
JojoMaque

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