Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clean Exit from InputBox


Is there a way to cleanly exit an InputBox if you select the CANCEL
button? Ideally, I would just like to have the user start over again.

When I select CANCEL I get a Run Time error, Type mismatch.

Below is the InputBox code I have in my macro (it is the first thing a
user sees when the macro is launced):


Code:
--------------------
NumFiles = InputBox("Enter number of files" & Chr(13) & Chr(13) & "Select ALL files in dialog box" & Chr(13) & Chr(13) & "When File|Open dialog box is displayed," & Chr(13) & "Click, Ctrl-Click or Shift-Click to select files", "Files", "", 3500, 3000)
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=552632

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Clean Exit from InputBox

Dim NumFiles as Long
Dim sAns as String
sAns = InputBox("Enter number of files" & Chr(13) & Chr(13) & "Select ALL
files in dialog box" & Chr(13) & Chr(13) & "When File|Open dialog box is
displayed," & Chr(13) & "Click, Ctrl-Click or Shift-Click to select files",
"Files", "", 3500, 3000)
if sAns = "" then exit sub
NumFiles = clng(sAns)

--
Regards,
Tom Ogilvy


"scantor145" wrote:


Is there a way to cleanly exit an InputBox if you select the CANCEL
button? Ideally, I would just like to have the user start over again.

When I select CANCEL I get a Run Time error, Type mismatch.

Below is the InputBox code I have in my macro (it is the first thing a
user sees when the macro is launced):


Code:
--------------------
NumFiles = InputBox("Enter number of files" & Chr(13) & Chr(13) & "Select ALL files in dialog box" & Chr(13) & Chr(13) & "When File|Open dialog box is displayed," & Chr(13) & "Click, Ctrl-Click or Shift-Click to select files", "Files", "", 3500, 3000)
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=552632


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 / VBA question ok = print, cancel = exit todd78 Excel Worksheet Functions 4 August 9th 07 04:42 PM
Clean up help Andy Excel Programming 6 February 4th 06 08:54 AM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM
=clean(a1) news.verizon.net Excel Programming 2 August 25th 03 11:08 PM


All times are GMT +1. The time now is 09:45 PM.

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

About Us

"It's about Microsoft Excel"