In VBA, there is 3 types of Newline characters.
- vbCr – Carriage Return CR
- vbLf – Line Feed LF
- vbCrLf – Carriage Return CR + Line Feed LF
Different Newline characters are for different OSs.
Linux and Mac OS X use LF
Windows uses CR + LF
Mac OS and Apply II family use CR.
You can append a Newline character by simple concatenation.
Private Sub CommandButton1_Click() Range("A1") = "1st" + vbCrLf + "2nd" End Sub
Done =)
Reference:
Thank you very much for this posting. It really saved me from all the confusions!!
LikeLike
You are welcome~ =)
LikeLike
Very clear post. Just one detail: Mac OS X still uses CR for new lines. You can check it via terminal (console).
LikeLike
Glad to know that it helps and thx for your comment. =)
LikeLike