I'm trying to make a button to delete just one row from a table on Excel using vba but when I press the button and select more than just one row or a lot of cells then deletes everything, I want to limit the selection from E to I (and no matters the number of row) Here is my code and thanks a lot, hope you can help me, I don't find anything similar yet.
Sub delete_a_row() Dim variable As Range On Error GoTo local_err CONFIRM = MsgBox("do you wanna delete a row?", vbYesNo + vbExclamation, "delete row") If (CONFIRM = vbYes) Then Set variable = Application.InputBox("select a row", "delete row", , , , , , 8) Range(variable.Address).Select Selection.Delete Shift:=xlUp End If local_err: End Sub
I know looks kinda messy, sorry for that I'm new on VBA