我开发了一个宏,可以在同一个工作簿中将列从一个工作表导入另一个工作表。这是有效的,但现在我想要的是,当我修改第一张纸中的单元格时,它不会在另一张纸张中粉碎它。相反,我希望将它添加到另一张纸的底部。
Public Sub Click()
Sheets("PTR").Range("B6").Select
lRow = Worksheets("Analyse").Range("C6").End(xlDown).Row
Worksheets("Analyse").Range("C6:C" & lRow).Copy Destination:=Sheets("PTR").Range("B6:B" & lRow)
Application.CutCopyMode = False
End Sub
答案 0 :(得分:0)
这是你在尝试什么? (的未测试强>)
我已对代码进行了评论,因此您不应该对其进行理解。如果你这样做,只需问:)
Public Sub Click()
Dim wsI As Worksheet, wsO As Worksheet
Dim lRowWsI As Long, lRowWsO As Long
'~~> Set your output sheet
Set wsO = ThisWorkbook.Worksheets("PTR")
'~~> Find the last row where the data needs to go
lRowWsO = wsO.Range("B" & wsO.Rows.Count).End(xlUp).Row + 1
'~~> Set Input Sheet
Set wsI = ThisWorkbook.Worksheets("Analyse")
With wsI
'~~> Find Last Row to get the range you want to copy
lRowWsI = .Range("C" & .Rows.Count).End(xlUp).Row
'~~> Do the final Copy
.Range("C6:C" & lRowWsI).Copy Destination:=wsO.Range("B" & lRowWsO)
End With
Application.CutCopyMode = False
End Sub
要查找最后一行,您可能希望查看THIS帖子。