更新时间:2022-02-27 22:11:45
关于您在做什么错,我建议您使用
As to what are you doing wrong, I suggest you use
Sub Concat()
Sheets("Sheet1").Select
Dim lRow As Long, i As Long
Dim rng As Range
Set rng = Range("A" & Rows.Count).End(xlUp)
Debug.Print rng.Address(External:=True)
lRow = rng.Row
For i = 2 To lRow
ActiveWorkbook.Sheets("Sheet2").Cells(i, 1) = Cells(i, 1) & Cells(i, 2)
Next i
End Sub
正在进行。我完全尝试了您使用的工具,并且对我有用(Excel 2010)。
to see what is going on. I tried exactly what you used and it worked for me (Excel 2010).
指定变量lRow不取任何值的含义将有所帮助。
Specifying what does "variable lRow is not taking any value" mean would help.
您也可以尝试或者
Sub Concat2()
Sheets("Sheet1").Select
Dim lRow As Long, i As Long
Dim rng As Range
Set rng = Range("A2").End(xlDown)
Debug.Print rng.Address(External:=True)
lRow = rng.Row
For i = 2 To lRow
ActiveWorkbook.Sheets("Sheet2").Cells(i, 1) = Cells(i, 1) & Cells(i, 2)
Next i
End Sub
如果您在源列A的中间没有空白单元格,则结果相同。
which should give the same result if yo do not have blank cells in the middle of the source column A.