ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting chr(10) from script (https://www.excelbanter.com/excel-programming/400991-inserting-chr-10-script.html)

Gav[_3_]

Inserting chr(10) from script
 
I am writing an OLE link from SAP to generate an Excel document and have
come accross a bit of a hurdle. After populating a cell with text I need to
insert carriage returns at specific points.

eg. I insert "This is my test text." into a cell. Then I want to insert
carriage returns after "is" and "test".

I've tried to record macros of me selecting after a character and pressing
alt-enter but in the macro shows the following "This is"& chr(10) &"my
test"& chr(10) &"text."

Is there an insert command I can use to insert a single character?

thanks

Gav



JW[_2_]

Inserting chr(10) from script
 
Try:
"This is" & vbLf & "my test" & vbLf & "text."

Gav wrote:
I am writing an OLE link from SAP to generate an Excel document and have
come accross a bit of a hurdle. After populating a cell with text I need to
insert carriage returns at specific points.

eg. I insert "This is my test text." into a cell. Then I want to insert
carriage returns after "is" and "test".

I've tried to record macros of me selecting after a character and pressing
alt-enter but in the macro shows the following "This is"& chr(10) &"my
test"& chr(10) &"text."

Is there an insert command I can use to insert a single character?

thanks

Gav



Gav[_3_]

Inserting chr(10) from script
 

"Gav" wrote in message
...
I am writing an OLE link from SAP to generate an Excel document and have
come accross a bit of a hurdle. After populating a cell with text I need to
insert carriage returns at specific points.

eg. I insert "This is my test text." into a cell. Then I want to insert
carriage returns after "is" and "test".

I've tried to record macros of me selecting after a character and pressing
alt-enter but in the macro shows the following "This is"& chr(10) &"my
test"& chr(10) &"text."

Is there an insert command I can use to insert a single character?

thanks

Gav


I thought that would happen. Half an hour getting knowhere then as soon as I
post I find the answer. :o)

ActiveCell.Characters(6, 0).Insert (Chr(10))




All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com