Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Inputbox method using type:=8 - How to Cancel?

Joe,

I have been happier using the InputBox function instead of the InputBox
method.
It returns a string and if cancel is clicked it returns a zero length string
..
As long as you want only want to determine one row then see how this work...

'------------------------
Sub TestIt2()
Dim MyNum As Variant
MyNum = "1"

DoAgain:
MyNum = InputBox(vbCr & "Enter row number", "Real Good Program", MyNum)
If Len(MyNum) = 0 Then
Rows(1).Select
Else
MyNum = Left(Abs(Val(MyNum)), 6)
If MyNum < 1 Or MyNum Rows.Count Then
MyNum = "Invalid Entry - Try Again"
GoTo DoAgain
Else
Rows(MyNum).Select
End If
End If
End Sub
'------------------------------

Regards,

Jim Cone
San Francisco, Ca
***********************
"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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inputbox type 64 (array) pete the greek Excel Discussion (Misc queries) 8 May 20th 23 11:44 AM
Exit Code Upon Cancel On Type 8 Input Box FARAZ QURESHI Excel Discussion (Misc queries) 2 March 31st 08 09:22 AM
InputBox / VBA question ok = print, cancel = exit todd78 Excel Worksheet Functions 4 August 9th 07 04:42 PM
Detecting Cancel in an InputBox Method Connie Excel Discussion (Misc queries) 2 October 19th 06 01:32 PM
how do i cancel the type blocking in the cell? ashley New Users to Excel 1 June 30th 05 01:35 AM


All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"