View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Charabeuh[_4_] Charabeuh[_4_] is offline
external usenet poster
 
Posts: 62
Default Macro to delete last entry of a column

Hello

This macro will delete the last two entries in the column of your active
cell.
(even if the column is empty, or has only one value in row 1)

Sub Delete_Last_2()

On Error Resume Next
Cells(Rows.Count, ActiveCell.Column).End(xlUp).Offset(-1, 0).ClearContents
On Error GoTo 0
Cells(Rows.Count, ActiveCell.Column).End(xlUp).ClearContents

End Sub








"Mel" a écrit dans le message de groupe de
discussion : ...
I want to delete the last 2 entries of column of data in excel 2007. The
column length varies each time I want to run the macro. I've tried
recording
a macro using the 'ctl down' shortcut then deleting the last two entries.
However, when I run the macro on a different data set it doesn't delete
the
last entries but deletes the data in the rows that was recorded in the
original macro.

Please could you advise me on the line of code I need to refer to the last
two entries of a column of any length.

Thank you!