Insert carriage returns at x characters

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
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


 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Book1
EF
100a bcabc
Sheet1
Cell Formulas
RangeFormula
E100E100=REPLACE(F100,2,0,CHAR(10))
 
Upvote 0
Not sure exactly what your suggestion is doing Irobbo.

I have tried but all it does is insert a CR at character 2.
 
Upvote 0
It's an example. You'll need to nest some formulas and change the position of the insertion values to get the desired result.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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