Reputation: 17
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
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