first of all, new to VBA.
I am implementing this solution how-to-merge-all-column-into-one-cell-in-excel[stackoverflow], but have a follow-on.
A1:I
A2:am
A3:a
A4:boy
my output is: Iamaboy
but I would like in one cell:
I
am
a
boy
Functions do not seem to return strings with vbNewLine
, chr(10)
or chr(13)
...
After the ampersand (&) symbol, press the spacebar and get the VBA constant “vbNewLine.” After the constant “vbNewLine,” press one more time space bar and add the ampersand (&) symbol. After the second ampersand (&) symbol, type one more space character, and add the next line sentence in double quotes. We have done it.
If you want to force a new line in a message box, you can include one of the following: The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf. The character codes for a carriage return and line feed, Chr(13) & Chr(10).
Use the line-continuation character, which is an underscore ( _ ), at the point at which you want the line to break. The underscore must be immediately preceded by a space and immediately followed by a line terminator (carriage return) or (starting with version 16.0) a comment followed by a carriage return.
One line of code:
Range("B1").Formula = join(application.transpose(Range("A1:A4")),vblf)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With