Excel VBA Code: The code only works for the first line

advertisements

I have the following code :

' Paste last value
    Range(Cells(LastRowP + 1, 10), Cells(LastRowP + 1, 10)).Select
    Selection.Cut
    Range(Cells(LastRowP + 1, 9), Cells(LastRowP + 1, 9)).Select
    ActiveSheet.Paste

This code should cut the content from column 10 and paste it in column 9.Unfortunately this is working only for the first entry (row 2 for example) for the other rows, it doesn't work. Can you help?

Thank you!


This should work:

Sub CutColumn()

   LastRow = Cells(Rows.Count, "J").End(xlUp).Row
   Range("J1:J" & LastRow).Cut Destination:=Range("I1:I" & LastRow)

End Sub