方法二:赋值法
模拟数据如图,假设在sheet1:
结果如图,假设在sheet2:
代码如下:
Sub Test_528_1()
Sheet1.Activate
Dim rng As Range, i&, j&, r&, c&, irow&
Set rng = [a1].CurrentRegion
r = rng.Rows.Count
c = rng.Columns.Count
ReDim arr(1 To r, 1 To c)
For j = 1 To c
irow = Cells(Rows.Count, j).End(xlUp).Row
For i = 1 To irow
arr(i + r - irow, j) = rng(i, j)
Next
Next
Sheet2.Activate
[a1].Resize(r, c) = arr
End Sub
如果第一行有标题,请适当修改代码。