0

I have an Excel 2013 workbook.

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

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.

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?

3
  • What error is the vbe showing? Commented Aug 9, 2016 at 5:39
  • None just stops and highlights that line no error. I have found that it is specific to the cut function as using copy works. Commented Aug 9, 2016 at 5:45
  • From your code I infer that the active sheet at the start of your sub isn't "_data", if so when you set NextRow it won't be on "_data" since you don't specify the worksheet. It should be Set NextRow = ToDataSheet.Range("B" & ToDataSheet.UsedRange.Rows.Count + 1) Commented Aug 9, 2016 at 6:50

1 Answer 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
Sign up to request clarification or add additional context in comments.

2 Comments

Perfectly simple and sweet.
Thanks sayth for your comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.