Michael Brenndoerfer
Michael Brenndoerfer

Reputation: 4066

Range, empty row in Excel vba

I've found a snippet for selecting the next empty row in excel, but when I run the macro it tells me that it throws a runtime error 1004. Any idea why?

Sub CopyValues()

Sheets("Report").Select
Range("B4:D10").Select
Selection.Copy
Sheets("Data").Select
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste

End Sub

And yes, the worksheet names are correct. Range("A1").End(xlDown).Offset(1, 0).Select throws the error

Upvotes: 1

Views: 321

Answers (1)

user2140173
user2140173

Reputation:

Sub CopyValues()
    Sheets("Report").Range("B4:D10").Copy _
        Destination:=Sheets("Data").Range("A" & Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row + 1)
End Sub

Upvotes: 1

Related Questions