Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inputbox method using type:=8 - How to Cancel?
Thanks to everyone for helping me solve my problem.
Once I saw I could use "On Error" to overcome the error, I simplified on Vasant's solution as follows: +++++++++++++++++++++++++++++ Sub PickRow ( ) dim mynum On Error Goto ErrorHandler Set mynum= Application.InputBox ( "Select Row" , type: = 8 ) "some code" ErrorHandler : "some code" (or nothing if you just want to stop the procedure!) End Sub +++++++++++++++++++++++++++++ This is all I needed on this occasion. Cheers Joe "Joe 90" wrote in message ... Thanks Vasant I'll give it a whirl today and report back Joe "Vasant Nanavati" wrote in message ... Hi Joe: You need something like the following awkward construction: Sub ForceRangeInput() Dim vResp As Variant Do Until TypeName(vResp) = "Range" On Error Resume Next Set vResp = Application.InputBox("Test", Type:=8) On Error GoTo 0 Loop vResp.EntireRow.Select End Sub It's tricky only because the InputBox can return two types, an object and a boolean. Regards, Vasant. Regards, Vasant. "Joe 90" wrote in message ... Hi, I have an input box that asks the user to select a row (by picking a cell). The dialog box provides for an Ok button and a Cancel button. If the user clicks the Cancel button I get an error in VBA. I want to create a rounded app so everything works and I have tried all ways to get this to go away but nothing I can do will make the inputbox accept a "Range object" as the default, and therefore allow the Cancel. All I get is a "Run time error 13, type mismatch" Here's the code: +++++++++++++++++++++++++++++++++++++++++++ Sub PickRow ( ) dim mynum set mynum = Application.InputBox ( "Select Row" , type: = 8 ) End Sub +++++++++++++++++++++++++++++++++++++++++++ I have tried putting a variable for a range, a range address, and a range reference in as default e.g. set mynum = Application.InputBox ( "Select Row" , , "$A$1" ,type: = 8 ) What am I doing wrong, or is this a vagary of the object model, that because I am choosing to seek a range object type, the Cancel button will always produce an error?? Hoping you can help.................................. Joe |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
inputbox type 64 (array) | Excel Discussion (Misc queries) | |||
InputBox / VBA question ok = print, cancel = exit | Excel Worksheet Functions | |||
Detecting Cancel in an InputBox Method | Excel Discussion (Misc queries) | |||
Inputbox method using type:=8 - How to Cancel? | Excel Programming | |||
Inputbox method using type:=8 - How to Cancel? | Excel Programming |