我在其他页面上有相同的代码,它工作正常,但在一个页面上它没有偏离第三行的粘贴,它只做到第一行可以有人帮忙吗?
Set wsInfoFrom = Worksheets("STP1st")
Set wsInfoTo = Worksheets("StowToPrime")
lastrow = wsInfoFrom.Range("B" & wsInfoFrom.Rows.Count).End(xlUp).Row
Set copyRange = wsInfoFrom.Range("B5:B" & lastrow)
wsInfoTo.Range("A1:A9999" & lastrow).ClearContents
copyRange.SpecialCells(xlCellTypeVisible).Copy wsInfoTo.Range("A" & Rows.Count).End(xlUp).Offset(3, 0)
答案 0 :(得分:0)
尝试下面稍加修改和更有条理的代码,我认为这就是你要做的事情:
Set wsInfoFrom = Worksheets("STP1st")
Set wsInfoTo = Worksheets("StowToPrime")
With wsInfoFrom
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
Set copyRange = .Range("B5:B" & lastrow)
End With
With wsInfoTo
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row ' <-- different last row in this sheet
.Range("A1:A" & lastrow).ClearContents
copyRange.SpecialCells(xlCellTypeVisible).Copy .Range("A" & .Rows.Count).End(xlUp).Offset(3, 0)
End With