【发布时间】:2016-12-21 02:14:59
【问题描述】:
我需要将多行选择中的多个单元格连接成一个带有换行符/回车符的字符串单元格
例如选择图片:
连接后应该是这样的:
我的代码将连接到一个单元格但不添加换行符:
Sub concat_3()
Dim row As Range
Dim cell As Range
Dim txt As String
For Each row In Selection
For Each cell In row.Cells
txt = txt & cell.Value
Next cell
txt = txt & vbCrLf
Next row
Selection.ClearContents
txt = Left(txt, Len(txt) - 2)
Selection(1).Value = txt
End Sub
【问题讨论】: