MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Inputbox Error


Posted by Harry Pilauf on February 18, 2002 5:23 PM

When I run the following code in a procedure , the input box comes up and if I press the cancel button I get an Run-time error "type mismatch"
I need to do the "set" part as I want to go to that cell further down the procedure - so as to delete the row where the cell was

Can anyone please help

Thanks
Harry


Sub delete_rows()

Dim anssort As Integer
Set myrange3 = Application.InputBox(prompt:="Please point to the row you want deleted", Left:=350, Top:=150, Type:=8)
If myrange3 = False Then
anssort = MsgBox("Do you wish to sort the data now ?", vbYesNo, "Sort ?")
If anssort = vbNo Then

endproc
Else: tim = 5
End If

Else

myrange3.Select
myrange3.EntireRow.delete shift:=x1up
End If
End Sub


Posted by Damon Ostrander on February 19, 2002 1:50 PM

Hi Harry,

There is no way to get the InputBox to "gracefully" exit on cancel when Type:=8. So what you have to do is this:

Dim anssort As Integer
Dim MyRange3 As Range
On Error Resume Next
Set MyRange3 = Application.InputBox(prompt:="Please point to the row you want deleted", Left:=350, Top:=150, Type:=8)
On Error GoTo 0
If MyRange3 Is Nothing Then
anssort = MsgBox("Do you wish to sort the data now ?", vbYesNo, "Sort ?")
End If


Keep Excelling.

Damon