Clean Exit from InputBox

S

scantor145

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:
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top