我在excel中有以下格式的数据
1 2
3 4
5 6
7 8
8 9
我希望输出为:1 2 3 4 5 6 7 8 9单行
答案 0 :(得分:2)
假设
A B
========
1) 1 2
2) 3 4
然后这将把数据放在C1:
Dim Data As Range, cell As Variant, buffer As String
Set Data = Range("A1:B1", Range("A1:B1").End(xlDown))
For Each cell In Data
If (buffer = "") Then
buffer = cell.Value
Else
buffer = buffer & " " & cell.Value
End If
Next
Range("C1").Value = buffer