ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need to insert line-feed in Excel concatenation (VB) (https://www.excelbanter.com/excel-programming/353018-need-insert-line-feed-excel-concatenation-vbulletin.html)

Susan W

Need to insert line-feed in Excel concatenation (VB)
 
I want to concatenate values from multiple cells into one cell. I want a
line-feed separating the values in the combined cell. I tried using the
ASCII character code (10 for linefeed, 13 for carriage return), but its not
working the way I did it.

Any help is greatly appreciated.



Niek Otten

Need to insert line-feed in Excel concatenation (VB)
 
="a"&CHAR(10)&"b"

FormatcellsAlignment, check Wrap text

--
Kind regards,

Niek Otten

"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell. I want a
line-feed separating the values in the combined cell. I tried using the
ASCII character code (10 for linefeed, 13 for carriage return), but its
not
working the way I did it.

Any help is greatly appreciated.





Chip Pearson

Need to insert line-feed in Excel concatenation (VB)
 
Susan,

Try something like

=A1&CHAR(10)&A2

or, in VBA

Range("B1").Value = Range("A1").Value & Chr(10) &
Range("A2").Value

Ensure that the cell has Wrap Text enabled (Format menu, Cells,
Alignment tab).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell.
I want a
line-feed separating the values in the combined cell. I tried
using the
ASCII character code (10 for linefeed, 13 for carriage return),
but its not
working the way I did it.

Any help is greatly appreciated.





Susan W[_2_]

Need to insert line-feed in Excel concatenation (VB)
 
Yes - the Chr(10) did it. Thanks very much!
Susan

"Chip Pearson" wrote:

Susan,

Try something like

=A1&CHAR(10)&A2

or, in VBA

Range("B1").Value = Range("A1").Value & Chr(10) &
Range("A2").Value

Ensure that the cell has Wrap Text enabled (Format menu, Cells,
Alignment tab).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell.
I want a
line-feed separating the values in the combined cell. I tried
using the
ASCII character code (10 for linefeed, 13 for carriage return),
but its not
working the way I did it.

Any help is greatly appreciated.






scabHead

Need to insert line-feed in Excel concatenation (VB)
 
I find that using vbLF is a bit more readible and is certainly faster to type
than CHR(10). Am I missing something here?

"Susan W" wrote:

Yes - the Chr(10) did it. Thanks very much!
Susan

"Chip Pearson" wrote:

Susan,

Try something like

=A1&CHAR(10)&A2

or, in VBA

Range("B1").Value = Range("A1").Value & Chr(10) &
Range("A2").Value

Ensure that the cell has Wrap Text enabled (Format menu, Cells,
Alignment tab).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell.
I want a
line-feed separating the values in the combined cell. I tried
using the
ASCII character code (10 for linefeed, 13 for carriage return),
but its not
working the way I did it.

Any help is greatly appreciated.






NickHK

Need to insert line-feed in Excel concatenation (VB)
 
vbLF, vbCR etc are certianly more clear to read, but have exactly the same
effect as Chr(10), Chr(13).
The only one that may make a difference is vbNewLine, which will give the
correct value on a PC or Mac.

NickHK

"scabHead" wrote in message
...
I find that using vbLF is a bit more readible and is certainly faster to

type
than CHR(10). Am I missing something here?

"Susan W" wrote:

Yes - the Chr(10) did it. Thanks very much!
Susan

"Chip Pearson" wrote:

Susan,

Try something like

=A1&CHAR(10)&A2

or, in VBA

Range("B1").Value = Range("A1").Value & Chr(10) &
Range("A2").Value

Ensure that the cell has Wrap Text enabled (Format menu, Cells,
Alignment tab).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell.
I want a
line-feed separating the values in the combined cell. I tried
using the
ASCII character code (10 for linefeed, 13 for carriage return),
but its not
working the way I did it.

Any help is greatly appreciated.








clara

Need to insert line-feed in Excel concatenation (VB)
 
Hi Mr.Pearson,

a1&char(10)&a2 works well, but how to make the containing cell collapse
automatically when it contains multiple lines

Clara
--
thank you so much for your help


"Chip Pearson" wrote:

Susan,

Try something like

=A1&CHAR(10)&A2

or, in VBA

Range("B1").Value = Range("A1").Value & Chr(10) &
Range("A2").Value

Ensure that the cell has Wrap Text enabled (Format menu, Cells,
Alignment tab).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan W" <Susan wrote in message
...
I want to concatenate values from multiple cells into one cell.
I want a
line-feed separating the values in the combined cell. I tried
using the
ASCII character code (10 for linefeed, 13 for carriage return),
but its not
working the way I did it.

Any help is greatly appreciated.







All times are GMT +1. The time now is 07:30 AM.

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