Wrap Text of Several Rows

tkat92

New Member
Joined
Oct 18, 2017
Messages
2
Hello,

I have around 20 rows of text and I want to wrap them all into one cell. Manually I would have to do the following:


  1. Copy text
  2. Paste the text into the cell
  3. Press Alt + Enter (From where I want the characters to start on a new line)

The data set I have is huge. Is there an efficient way for me to do this? I have included a table below FYI. Italicized data is how I have the cells. Underlined is how I want them. THANKS!
Public - 20%
Private - 40%
Sell - 30%
Remain - 10%
Public -20%
Private - 40%
Sell - 30%
Remain - 10%

<tbody>
</tbody>
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
tkat92,

Welcome to the Board.

If you're comfortable with a vba approach...

Code:
Sub ConcatenateText()
Dim arr As Variant, i As Long, txt As String
arr = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
For i = LBound(arr) To UBound(arr)
    If txt <> "" Then
        txt = txt & Chr(10) & arr(i, 1)
    Else
        txt = arr(i, 1)
    End If
Next i
Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1).Value = txt
End Sub

Cheers,

tonyyy
 
Last edited:
Upvote 0
If you're comfortable with a vba approach...

Code:
Sub ConcatenateText()
Dim arr As Variant, i As Long, txt As String
arr = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
For i = LBound(arr) To UBound(arr)
    If txt <> "" Then
        txt = txt & Chr(10) & arr(i, 1)
    Else
        txt = arr(i, 1)
    End If
Next i
Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1).Value = txt
End Sub
You can also do that with just a single line of code (albeit a rather long one)...
Code:
[table="width: 500"]
[tr]
	[td]Sub ConcatenateText2()
  Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1).Value = Join(Application.Transpose(Range("A1", Cells(Rows.Count, "A").End(xlUp))), vbLf)
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top