First time poster here
I have an outer loop which copies rows (A11:G11) to rows (A67:G67) into row (A6:G6) one row at a time in Sheet1. Everytime the next row is copied into A6:G6, it should replace the previous copied row. For each row that is copied, there is an inner loop which should copy cells B6 to F6 into cell A6 in Sheet2 one cell at a time.
So when A11:G11 is copied into A6:G6, cells B6 to F6 from sheet1 is copied one cell at a time into cell A6 in sheet2 and the first inner loop is complete. The program must now return back to sheet1 and copy A12:G12 into A6:G6, then copy cells B6 to F6 from sheet1 to A6 in sheet2 one cell at a time and the process repeats itself until A67:G67.
I have made the following script but it doesn't work any further than for A11:G11 and remains in the wrong sheet.
I am very new to VBA code and hope someone can fix it for me.
I have an outer loop which copies rows (A11:G11) to rows (A67:G67) into row (A6:G6) one row at a time in Sheet1. Everytime the next row is copied into A6:G6, it should replace the previous copied row. For each row that is copied, there is an inner loop which should copy cells B6 to F6 into cell A6 in Sheet2 one cell at a time.
So when A11:G11 is copied into A6:G6, cells B6 to F6 from sheet1 is copied one cell at a time into cell A6 in sheet2 and the first inner loop is complete. The program must now return back to sheet1 and copy A12:G12 into A6:G6, then copy cells B6 to F6 from sheet1 to A6 in sheet2 one cell at a time and the process repeats itself until A67:G67.
I have made the following script but it doesn't work any further than for A11:G11 and remains in the wrong sheet.
I am very new to VBA code and hope someone can fix it for me.
VBA Code:
Sub Copy_in_loop()
Dim x, y As Integer 'set variable for numbers of Rows, Columns to deal
' Set numrows = number of rows of data starts from A11 till last
NumRows = Worksheets("Sheet1").Range("A11", Range("A11").End(xlDown)).Rows.Count
' Select first cell to start with
Worksheets("Sheet1").Range("A11:G11").Select
' Establish "For" loop to loop "numrows" number of times
For x = 1 To NumRows
'to copy active cell to range("A6:G6") Override values
ActiveCell.Range("A1:G1").Copy Range("A6:G6")
' Select the first Activity from the first process chain
Worksheets("Sheet1").Range("B6").Select
'Establish "For" loop to loop 1 -5
For y = 1 To 5
'to copy active cell to range A6 in Worksheet Activity Database
ActiveCell.Range("B1").Copy Worksheets("Sheet2").Range("A6")
'Selects cell left 1 column to active cell.
ActiveCell.Offset(0, 1).Select
Next
' Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next
End Sub
Attachments
Last edited by a moderator: