I have a data in the first column that we have to copy and paste in next empty row in a column in another sheet. I have used below code for that which is working.
- Code: Select all
Sub M2()
Dim lr, er As Integer
lr = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For i = 2 To lr
er = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet1.Cells(i, 1).Copy
Sheet2.Paste Destination:=Worksheets("Sheet2").Cells(er, 1)
Next i
End Sub
Here i want to paste data from next empty row in the another sheet using "If" condition. For eg: if in the 2nd row of the 4th column contains value as "Between" then only i want to copy data from 2nd row 1st column from sheet1 and paste it in next empty row in 1st column in another sheet.