我想将活动单元格复制到另一张称为“评论”的工作表的A列中的最后一个空闲单元格中。
我尝试了以下代码:
Sub Macro3()
'Keyboard Shortcut: Ctrl y
Dim LastRowMaster As Long
'Take the cell I'm in
ActiveCell.Select
'Copy it
Selection.Copy
'Go to the sheet I want to paste into
Sheets("comments").Select
'Find the last row in my sheet "comments" and +1
LastRowMaster = Worksheets("comments").Cells(Worksheets("comments").Rows.Count, 1).End(xlUp).Row + 1
'Choose the last free cell in column A
Range("A:").Copy Destination:=ThisWorkbook.Worksheets("comments").Cells(LastRowMaster, "A")
'Copy my paste
ActiveSheet.Paste
End Sub
我遇到错误
“ object_global的方法'范围'失败
在此行:
Range("A:").Copy Destination:=ThisWorkbook.Worksheets("comments").Cells(LastRowMaster, "A")
答案 0 :(得分:1)
答案 1 :(得分:0)
所以代码会是这样吗?
Sub Macro3()
Dim LastRowMaster As Long
With Worksheets("comments")
LastRowMaster = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
ActiveCell.Copy Destination:=.Cells(LastRowMaster, "A").Value = ActiveCell.Value
End With
End Sub
出现错误。我恰好错过了一个点/空白之类的东西。 奥阿,我看不到问题。
Range类的复制方法失败
答案 2 :(得分:0)
这应将您的活动单元格复制到A列中下一个空单元格的“评论”页上:
Sub Macro3()
Dim LastRowMaster As Long
With Worksheets("comments")
LastRowMaster = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Cells(LastRowMaster, "A").Value = ActiveCell.Value
End With
End Sub