The answer is as tlewin said
=ConcatenateRange(A1:A4,CHAR(10))
Or, alternatively, using [alt-enter], you can write it like this:
=ConcatenateRange(A1:A4," ")
βBut wait,β you say, βI tried it, and it doesn't work!β
Well, you see, when you manually enter something like I[alt-enter]am[alt-enter]a[alt-enter]boy in Excel or even execute an instruction like [A1] = "I" & vbNewLine & "am" Excel automatically changes the formatting of the cells and enables word wrap. Word wrap is required to display lines in a cell. However, if you return a row with a line in it from UDF Excel, it does not update the format.
I can imagine two possible solutions:
- Manually enable word wrap in any cell in which you use this feature in
- (Not recommended) Save the link in
Application.Caller when calling UCF ConcatenateRange, then set the call to Application.OnTime(now, "AddWordWrap") and write the AddWordWrap routine so that it uses the saved link to add the wordwrap formatting to the cell (this is because you cannot update cell format in UDF). This method is erroneous and problematic.
source share