我的代码连接表“数据”第一行的列的值,并将结果写入表格“插入”单元格A1中。按行逐列连接列值
错误在于下一行的连接结果被添加到表格“插入”A1中的第一个结果的末尾,依此类推。结果应该逐行写入A列的“Insert”表中。
我的代码有什么问题?
Sub InsertStatementRow()
Dim x As String
Dim rng As Range
Dim cel As Range
Dim ColMax As Integer
Dim i As Long
Sheets("Data").Select
ColMax = Cells(1, Columns.Count).End(xlToLeft).Column
row = 1
Do While Cells(row, "A").Value <> ""
With Worksheets("Data")
i = 1
Set rng = Range(.Cells(i, 1), .Cells(i, ColMax))
End With
For Each cel In rng
x = x & cel.Value
Next
Sheets("Insert").Cells(i, 1).Value = x
row = row + 1
Loop
End Sub
感谢您的帮助!