Hello,
I'm a very beginner user of macros, and when a erro comes up, I have no idea how to fix it. Could you guys help me?
I have a macro to add row or delete rows to the table, and I'm using a message box to do it.
The problem is, when I select the option "Cancel" the "run-time error '13' " type mismatch, comes up. And when I degub it, the line " MyInput = InputBox(Msg, Title)" is selected in yellow.
how to fix it?
Sub AddDeleteRow()
ActiveSheet.Unprotect Password:="secret"
Dim Msg, Title As String
Dim MyInput As Integer
' Define message."
Msg = "Would you like to Add or Delete last row? " _
& vbNewLine & "Enter 1 to Add row" & vbNewLine _
& "Enter 2 to Delete last row"
Title = "Add or Delete last row" ' Define title.
MyInput = InputBox(Msg, Title)
Select Case MyInput
Case 1
MsgBox "Adding row"
Range("A4").End(xlDown).ListObject.ListRows.Add AlwaysInsert:=False
Case 2
MsgBox "Deleting last row"
End Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="secret"
End Sub
Thanks in advance
Michell
Bookmarks