Forum Discussion

Rory3's avatar
Rory3
Copper Contributor
Feb 04, 2022
Solved

deleting entire row using VBA

HI all.   I'm trying to make a form for data entry and I need to write a code for the delete button on the form. I have copied the following form my excel sheet.   Sub ENTRY_DELETE() With Sheet1 ...
  • HansVogelaar's avatar
    Feb 04, 2022

    Rory3 

    Like this:

    Sub ENTRY_DELETE()
        Dim EntryRow As Long
        If MsgBox("ARE YOU SURE YOU WANT TO DELETE THIS ENTRY?", vbYesNo, "DELETE ENTRY") = vbNo Then Exit Sub
        With Sheet1
            If .Range("B3") = "" Then Exit Sub
            EntryRow = .Range("B3").Value
            .Range("A" & EntryRow).EntireRow.Delete
        End With
    End Sub

Resources