View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Basilisk96 Basilisk96 is offline
external usenet poster
 
Posts: 37
Default How can I select a range manually with the mouse?

dan,
For completeness' sake, are you using something like this?

Sub GetCustomRange()
Dim MyRangeRef As Range
On Error GoTo Select_Cncled
Set MyRangeRef = Application.InputBox("Select the range of cells",
"Reference?", , , , , , 8)
Exit Sub
Select_Cncled:
MsgBox "you cancelled the previous message, you naughty!"
End Sub

I'm not sure that there is a way to catch the "The formula you typed
contains an error" issue - since it does not seem to be an error that
fires an event back to VBA; it's simply a warning to the end user,
sort of saying, "Give me something to work with before you press OK,
dummy!" :-)
Error 424, on the other hand, is generated because upon pressing
Cancel, the input box is destroyed and the above code does not assign
the expected object to MyRangeRef; therefore, VBA complains by raising
a catchable error, to which the error handles courteously responds.

Learning something new every day,
-Basilisk96

On Oct 25, 8:27 pm, dan dungan wrote:
Sorry I sent the last message before I was finished typing.

Anyway, If I choose the cancel button, the procedure returns runtime
error 424--object required.

Also, I could never get the procedure to go to the error handler.

Please help me understand the error handling.

Thanks,

Dan