ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   New Line in code to worksheet cell? (https://www.excelbanter.com/excel-programming/339752-new-line-code-worksheet-cell.html)

CG Rosén

New Line in code to worksheet cell?
 
Good Evening Group,

Is it possible to force a new line by code after each textstring that goes
into
Sheets("Sheet1").Cells(1, 1). This cell is formated as "Wrap Text". The
length
of the textstring is variable. (See code below).

Sheets("Sheet1").Cells(1, 1) = _
Sheets("Sheet2").Cells(1, 1) & " " & Sheets("Sheet2").Cells(1, 2) & " " & _
Sheets("Sheet2").Cells(1, 3) & " " & Sheets("Sheet21").Cells(1, 4) & " " &
_
Sheets("Sheet2").Cells(1, 5) & " " & Sheets("Sheet2").Cells(1, 6)

Grateful for any help.

Brgds

CG Rosén



Tom Ogilvy

New Line in code to worksheet cell?
 
Sheets("Sheet1").Cells(1, 1) = _
Sheets("Sheet2").Cells(1, 1) & chr(10) & _
Sheets("Sheet2").Cells(1, 2) & chr(10) & _
Sheets("Sheet2").Cells(1, 3) & chr(10) & _
Sheets("Sheet2").Cells(1, 4) & chr(10) & _
Sheets("Sheet2").Cells(1, 5) & chr(10) & _
Sheets("Sheet2").Cells(1, 6)

--
Regards,
Tom Ogilvy

"CG Rosén" wrote in message
...
Good Evening Group,

Is it possible to force a new line by code after each textstring that goes
into
Sheets("Sheet1").Cells(1, 1). This cell is formated as "Wrap Text". The
length
of the textstring is variable. (See code below).

Sheets("Sheet1").Cells(1, 1) = _
Sheets("Sheet2").Cells(1, 1) & " " & Sheets("Sheet2").Cells(1, 2) & " " &

_
Sheets("Sheet2").Cells(1, 3) & " " & Sheets("Sheet21").Cells(1, 4) & " "

&
_
Sheets("Sheet2").Cells(1, 5) & " " & Sheets("Sheet2").Cells(1, 6)

Grateful for any help.

Brgds

CG Rosén





Ron de Bruin

New Line in code to worksheet cell?
 
Hi CG Rosén

Try

With Sheets("Sheet2")
Sheets("Sheet1").Cells(1, 1).Value = _
.Cells(1, 1).Value & Chr(10) & .Cells(1, 2).Value & Chr(10) & _
.Cells(1, 3).Value & Chr(10) & .Cells(1, 4).Value & Chr(10) & _
.Cells(1, 5).Value & Chr(10) & .Cells(1, 6).Value
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"CG Rosén" wrote in message ...
Good Evening Group,

Is it possible to force a new line by code after each textstring that goes into
Sheets("Sheet1").Cells(1, 1). This cell is formated as "Wrap Text". The length
of the textstring is variable. (See code below).

Sheets("Sheet1").Cells(1, 1) = _
Sheets("Sheet2").Cells(1, 1) & " " & Sheets("Sheet2").Cells(1, 2) & " " & _
Sheets("Sheet2").Cells(1, 3) & " " & Sheets("Sheet21").Cells(1, 4) & " " & _
Sheets("Sheet2").Cells(1, 5) & " " & Sheets("Sheet2").Cells(1, 6)

Grateful for any help.

Brgds

CG Rosén





All times are GMT +1. The time now is 05:37 PM.

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