Home » excel » How do i delete the last row from a separate excel sheet VBA

How do i delete the last row from a separate excel sheet VBA

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a button that is on sheet2 and i am trying to delete the last row in sheet1 using VBA.

When i delete the row, i dont want my screen to go to sheet1.

This was happening when i tried to use .activate.

Private Sub CommandButton3_Click()

ActiveSheet.Cells(Rows.Count, "A").End(xlUp).EntireRow.Delete


End Sub
How to&Answers:

If the name of the first sheet is Sheet1 then use:

Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).EntireRow.Delete