Excel VBA - 激活工作表上的下一行错误

时间:2022-11-19 23:54:38

I have an Excel 2013 workbook.

我有一个Excel 2013工作簿。

I was utilising this SO Answer for Copy and find next blank Row

我正在利用这个SO答案复制并找到下一个空行

My code is

我的代码是

Sub Save()
    Dim NextRow As Range
    Set CopyZone = Worksheets("Sheet1").Range("A2:AO289")
    Set ToDataSheet = Worksheets("_data")
    Set NextRow = Range("B" & ToDataSheet.UsedRange.Rows.Count + 1)
    CopyZone.Cut
    ToDataSheet.Activate
    NextRow.PasteSpecial Paste:=xlValues, Transpose:=False
    Application.CutCopyMode = False
    Set NextRow = Nothing
End Sub

Copyzone is the output from my first sheet which has the newly formatted data. I set DataSheet to my to data sheet ("_data"), however it goes into debug on the line.

Copyzone是我的第一张工作表的输出,它包含新格式化的数据。我将DataSheet设置为我的数据表(“_data”),但它在线上进行调试。

NextRow.PasteSpecial Paste:=xlValues, Transpose:=False

How do I get it to complete a paste the cut data into the to sheet on the next blank line?

如何将剪切数据粘贴到下一个空白行的工作表中?

1 个解决方案

#1


3  

Hope the below code solves your problem

希望以下代码解决您的问题

Sub Save()
    Set CopyZone = Worksheets("Sheet1").Range("A2:AO289")
    Set ToDataSheet = Worksheets("_data")
    CopyZone.Cut Destination:=ToDataSheet.Range("B" & ToDataSheet.UsedRange.Rows.Count + 1)
End Sub

#1


3  

Hope the below code solves your problem

希望以下代码解决您的问题

Sub Save()
    Set CopyZone = Worksheets("Sheet1").Range("A2:AO289")
    Set ToDataSheet = Worksheets("_data")
    CopyZone.Cut Destination:=ToDataSheet.Range("B" & ToDataSheet.UsedRange.Rows.Count + 1)
End Sub