This should be a simple thing, but I still manage to mess it up.
In a workbook there are two sheets, A and B.
In sheet A there are 1000 rows and 7 columns. (the numbers of rows will vary.) Col A will always be filled with data (no empty cells before last row)
In sheet B there is a range, A1 to G1 to last row. Last row will vary.
What I need to do to copy the complete range in sheet B, and copy it in after each row in sheet A.
I am using this code, but something is wrong. In the example the range in sheet B has 30 rows.
In a workbook there are two sheets, A and B.
In sheet A there are 1000 rows and 7 columns. (the numbers of rows will vary.) Col A will always be filled with data (no empty cells before last row)
In sheet B there is a range, A1 to G1 to last row. Last row will vary.
What I need to do to copy the complete range in sheet B, and copy it in after each row in sheet A.
I am using this code, but something is wrong. In the example the range in sheet B has 30 rows.
VBA Code:
Sub CopyPasteRangeN_Times()
Worksheets("A").Activate
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim LastrowA As Long, LastrowB As Long, i As Long
LastrowA = Range("A" & Rows.Count).End(xlUp).Row
Worksheets("B").Activate
Sheets("Sheet B").Range("A1:G" & Cells(Rows.Count, "A").End(xlUp).Row).Copy
Worksheets("A").Activate
For i = 39 To Lastrow Step 39
Range("A" & i).Paste
Next i
End Sub