我正在编写代码,我想做的就是从一张表中复制数据并将其粘贴到另一张具有表格设置的表中。
我的代码正在做我想要做的事情,但是,表格不会调整大小以包含所有复制的行,只有复制数据的第一行进入表格。其余的被格式化为不在表格中。
这是我运行代码后的样子
Sub LastRowInOneColumn()
Dim LastRow As Longenter image description here
Dim i As Long, j As Long
'Find the last used row in a Column
With Worksheets("First Page")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
'first row number where you need to paste values in Sheet1'
With Worksheets("Report")
j = .Cells(.Rows.Count, "A").End(xlUp).Row '+ 1
End With
For i = 1 To LastRow
With Worksheets("First Page")
'If .Cells(i, 1).Value = "X" Then
.Rows(i).Copy Destination:=Worksheets("Report").range("A" & j)
j = j + 1
'End If
End With
Next i
End Sub