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?

Community
  • 1
  • 1
sayth
  • 6,696
  • 12
  • 58
  • 100
  • What error is the vbe showing? – Julian Kuchlbauer Aug 09 '16 at 05: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. – sayth Aug 09 '16 at 05: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)` – Vincent G Aug 09 '16 at 06:50

1 Answers1

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
Karthick Gunasekaran
  • 2,697
  • 1
  • 15
  • 25