Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you can give this a try:
Sub Del_Row() ' Ask user for the row number Dim RowToDelete As Long RowToDelete = Application.InputBox( _ Prompt:="Please enter the row number you wish to delete, eg: 23", _ Title:="Which Row Do You Wish to Delete?", Type:=1) ' exit sub if user presses 'cancel' If RowToDelete = 0 Then Exit Sub End If If RowToDelete 20 Then Rows(RowToDelete).EntireRow.Delete Else MsgBox "Sorry! You cannot delete This row." End If End Sub -- Gary "Tendresse" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
FANTASTIC ... it's working perfectly.
Thank you soooo much, GKeramidas :) "GKeramidas" wrote: you can give this a try: Sub Del_Row() ' Ask user for the row number Dim RowToDelete As Long RowToDelete = Application.InputBox( _ Prompt:="Please enter the row number you wish to delete, eg: 23", _ Title:="Which Row Do You Wish to Delete?", Type:=1) ' exit sub if user presses 'cancel' If RowToDelete = 0 Then Exit Sub End If If RowToDelete 20 Then Rows(RowToDelete).EntireRow.Delete Else MsgBox "Sorry! You cannot delete This row." End If End Sub -- Gary "Tendresse" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error 13 type mismatch input box | Excel Discussion (Misc queries) | |||
Type Mismatch: array or user defined type expected | Excel Programming | |||
Type mismatch using rnge as Range with Type 8 Input Box | Excel Programming | |||
input box date type mismatch | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming |