Excel macro for data formatting
I have data in excel开发者_如何学C in following format
1 2
3 4
5 6
7 8
8 9
I want output as : 1 2 3 4 5 6 7 8 9 in a single row
Assuming
A B
========
1) 1 2
2) 3 4
Then this will put the data in 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
精彩评论