在第一张图像中输入数据,然后在第二列H列中输入数据。
答案 0 :(得分:1)
试试这个:
=SUBSTITUTE(TRIM(SUBSTITUTE(A1,CHAR(10)," "))," ",CHAR(10))
或等效的VBA:
Sub test()
With Range("D1:D10")
.Replace Chr(10), " "
.Value = Evaluate("INDEX(TRIM(" & .Address & "),)")
.Replace " ", Chr(10)
.WrapText = True
End With
End Sub
答案 1 :(得分:0)
这是一种连接方法,可以避免任何不必要的分隔符:
Public Function StitchValues(rIn As Range) As String
Dim r As Range, v As Variant
StitchValues = ""
For Each r In rIn
v = r.Text
If v <> "" Then
If StitchValues = "" Then
StitchValues = v
Else
StitchValues = StitchValues & vbLf & v
End If
End If
Next r
End Function
所以在 H1 中你会输入:
<强> = StitchValues(B1:E1)强>
然后打开文字换行,调整行高等等。