Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default On error resume next

Hi All,
The following code returns an error if the user doesnt select a
range, with the error message "The formula you typed contains
an error."
Any assistance would be much appreciated.[Excel 2003]

Public Sub TestError()
Dim cellsSelected As Range
On Error Resume Next
Set cellsSelected = _
Application.InputBox(prompt:="Select a cell range", _
Type:=8)
On Error GoTo 0
If cellsSelected Is Nothing Then Exit Sub
End Sub

--
HJN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default On error resume next

This will cure the message, but it will not let you pass the input box
without either selecting a range or clicking cancel. Give it a try.

Public Sub TestError()
Dim cellsSelected As Range
Application.DisplayAlerts = False
On Error Resume Next
Set cellsSelected = _
Application.InputBox(prompt:="Select a cell range", _
Type:=8)
If Err.Number 0 Then
MsgBox "You did not select a range"
Exit Sub
End If
On Error GoTo 0
Application.DisplayAlerts = True
If cellsSelected Is Nothing Then Exit Sub
End Sub




"Hennie Neuhoff" wrote in message
...
Hi All,
The following code returns an error if the user doesn't select a
range, with the error message "The formula you typed contains
an error."
Any assistance would be much appreciated.[Excel 2003]

Public Sub TestError()
Dim cellsSelected As Range
On Error Resume Next
Set cellsSelected = _
Application.InputBox(prompt:="Select a cell range", _
Type:=8)
On Error GoTo 0
If cellsSelected Is Nothing Then Exit Sub
End Sub

--
HJN



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default On error resume next

Hi

You have to set Excel up to break on unhandled errors only, now I
guess it break on all errors.

In the VBA editor goto Tools Options General In 'Error Trapping'
section, mark ' Break on unhandled errors.

Hopes this helps.
Per

On 24 Sep., 04:22, Hennie Neuhoff
wrote:
Hi All,
The following code returns an error if the user doesn’t select a
range, with the error message "The formula you typed contains
an error."
Any assistance would be much appreciated.[Excel 2003]

Public Sub TestError()
Dim cellsSelected As Range
On Error Resume Next
Set cellsSelected = _
Application.InputBox(prompt:="Select a cell range", _
Type:=8)
On Error GoTo 0
If cellsSelected Is Nothing Then Exit Sub
End Sub

--
HJN


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 Johan Excel Programming 8 August 25th 09 08:40 PM
on error resume next filo666 Excel Programming 7 January 26th 06 06:42 PM
On Error Resume Next ? Nigel Excel Programming 4 August 11th 05 09:07 AM
On Error Resume Next Nigel Excel Programming 3 August 10th 05 03:34 PM
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:48 PM.

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"