Hi
I seek for way to avoid copy data repeatedly to the bottom after data have alredy existed . for instance if I have data in sheet TABLE 1 up to row 55 , then will copy after this row and start from row 56 . the code does that but the problem will repeat copying to the bottom when run the macro every time . so what I want clearing data after last row contains data have already existed . the lastrow contains data will change row 55 or 66 or 44 so should copy after the lastrow contains data without copy to the bottom repeatedly . just replace after lastrow contains data .
Sub copyItems()
Dim lRow1 As Long, lRow2 As Long
Dim Purchase As Worksheet
Set Purchase = Worksheets("PURCHASE")
lRow1 = Worksheets("Table 1").Cells(Rows.Count, 1).End(xlUp).Row
lRow2 = Purchase.Cells(Rows.Count, 1).End(xlUp).Row
With Worksheets("Table 1")
For i = 2 To lRow2
.Cells(lRow1 + i - 1, 1).Value = .Cells(lRow1 + i - 2, 1).Value + 1
.Cells(lRow1 + i - 1, 2).Value = Purchase.Cells(i, 2).Value
.Cells(lRow1 + i - 1, 3).Value = Purchase.Cells(i, 3).Value
Next
End With
End Sub
thanks