cooper88
cooper88

Reputation: 17

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

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

Upvotes: 1

Views: 494

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

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

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

Upvotes: 2

Related Questions