T
Tendresse
Hello all, I'm not sure what i am doing wrong and need your help please.
I wrote a code that asks the user for the row number they wish to delete.
But i keep getting the following error message:
Run-Time error '13' - Type mismatch.
Here is the code i wrote:
Sub Del_Row()
' Ask user for the row number
Dim RowToDelete As Long
RowToDelete = InputBox( _
Prompt:="Please enter the row number you wish to delete, eg: 23", _
Title:="Which Row Do You Wish to Delete?")
' exit sub if user presses 'cancel'
If RowToDelete = "" Then
Exit Sub
End If
if RowToDelete > 20 then
Rows(RowToDelete).delete
Else
MsgBox "Sorry! You cannot delete This row."
End If
End Sub
When i run the macro, i get the inputbox asking me for the number but when i
press cancel or enter a number i keep getting the above error message. Any
ideas?
I'm using Excel 2003
Thanks in advance
Tendresse
I wrote a code that asks the user for the row number they wish to delete.
But i keep getting the following error message:
Run-Time error '13' - Type mismatch.
Here is the code i wrote:
Sub Del_Row()
' Ask user for the row number
Dim RowToDelete As Long
RowToDelete = InputBox( _
Prompt:="Please enter the row number you wish to delete, eg: 23", _
Title:="Which Row Do You Wish to Delete?")
' exit sub if user presses 'cancel'
If RowToDelete = "" Then
Exit Sub
End If
if RowToDelete > 20 then
Rows(RowToDelete).delete
Else
MsgBox "Sorry! You cannot delete This row."
End If
End Sub
When i run the macro, i get the inputbox asking me for the number but when i
press cancel or enter a number i keep getting the above error message. Any
ideas?
I'm using Excel 2003
Thanks in advance
Tendresse