Feb 03 2022 09:18 PM
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 If MsgBox("ARE YOU SURE YOU WANT TO DELETE THIS ENTRY?", vbYesNo, "DELETE ENTRY") = vbNo Then Exit Sub
If .Range("B3") = Empty Then Exit Sub EntryRow = .Range("B3").Value
.Range(EntryRow & "." & EntryRow).EntireRow.Delete .Range("D13").Select
End With
End Sub
Im very new to this so any help would be appreciated.
Thanks.
Feb 04 2022 03:31 AM
SolutionLike 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
Feb 05 2022 07:41 PM - edited Feb 05 2022 07:42 PM
Hi @Hans Vogelaar ,
Yes, That worked perfectly Thank you very much.
Feb 04 2022 03:31 AM
SolutionLike 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