Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default On Error Resume Next

Error handling will not work if input box "Cancel" button is selected. I will get an error message, error #13, < Type Mismatch . What's going on here?

On Error Resume Next 'turn on error handling
dteDate = CDate(InputBox("Enter ending date for projection", Default:=Date))
If Err.Number 0 Then 'trap error if user clicks the cancel button
Exit Sub
End If
On Error GoTo 0 'reinstate normal error procedures


D.S.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default On Error Resume Next

Clicking the Cancel button does not raise an error in and
of itself, it returns a zero length string. The error is
occurring because you are trying to store a zero length
string in a Date variable. Instead, try this:

strInput = InputBox("Enter the Date", Default:=Date)
If strInput < "" Then
dteDate = CDate(strInput)
Else
MsgBox "No Date Selected..."
<jump to exit routine
End If

Mike.

-----Original Message-----
Error handling will not work if input box "Cancel" button

is selected. I will get an error message, error #13, <
Type Mismatch . What's going on here?

On Error Resume Next 'turn on error handling
dteDate = CDate(InputBox("Enter ending date for

projection", Default:=Date))
If Err.Number 0 Then 'trap error if user clicks the

cancel button
Exit Sub
End If
On Error GoTo 0 'reinstate normal error procedures


D.S.

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
On error resume next not working cluckers Excel Discussion (Misc queries) 3 November 25th 09 08:12 PM
Autofill & On Error Resume Next Dandelo Excel Discussion (Misc queries) 2 August 21st 08 07:14 PM
On Error Resume Next problem Jim May Excel Discussion (Misc queries) 14 November 2nd 07 12:27 PM
On error resume next problem freekrill Excel Discussion (Misc queries) 2 December 7th 05 12:51 AM
On Error Resume Next Mike[_58_] Excel Programming 3 November 23rd 03 05:09 PM


All times are GMT +1. The time now is 05:42 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"