I have used the below code to copy selected rows ("x") of data from one worksheet ("QBank") to another ("TestSheet") within the same workbook.
1. "QBank" worksheet has heading in row one so it will start checking the data in row 2
2. Column D does not have any empty cells.
3. "TestSheet" worksheet will have headings in the first 5 rows so the data will start copying in row 6.
Set i = Sheets("QBank")
Set e = Sheets("TestSheet")
d = 5
j = 2
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "x" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
j = j + 1
"TestSheet" worksheet has other data in it which I do not want to overwrite from row 20 onwards, how can I insert the number of rows above this when copying the data from the "QBank" worksheet to preserve everything below if more than 15 rows are selected in the "QBank" worksheet?