Chuk_99
Chuk_99

Reputation: 1

VBA Copy and Paste Macro which Loops

New to VBA and simply wanted to create a macro which copies the tables within a specified range and pastes in the next available empty rows. What happens is that every time I run it it pastes into the same range i.e. B12 and don't know how to amend...

Sub CopyRange2()

Range("A1:I9").Select
Selection.Copy
Range("B12").Select
ActiveSheet.Paste
Application.CutCopyMode = False

End Sub

Upvotes: 0

Views: 31

Answers (1)

SRA
SRA

Reputation: 219

Would like to know why you have specified cell B12 ??

The below code will work if you just want to paste the data in the next available empty rows.

Sub CopyRange2()

Dim lastrow As Long

lastrow = Range("A" & Rows.Count).End(xlUp).Row

Range("A1:I9").Select
Selection.Copy

Range("A" & lastrow + 1).Select
ActiveSheet.Paste
Application.CutCopyMode = False


End Sub

Upvotes: 1

Related Questions