EXIT SUB UPON VBCANCEL

F

FARAZ QURESHI

I have the following code but upon clicking the cancel button it is resulting
in Run-time error '424' Object required.

Any suggestions?

Set SRC = Application.InputBox(PROMPT:="Select The First Cell of The
Source Data." & vbNewLine & vbNewLine, Type:=8)
If vbCancel Then
Exit Sub
End If
 
D

Daniel.C

On Error Resume Next
Set SRC = Application.InputBox(PROMPT:="Select The First Cell of The
Source Data." & vbNewLine & vbNewLine, Type:=8)
If Err.Number <> 0 Then Exit Sub
On Error GoTo 0

HTH
Daniel
 
D

Dave Peterson

Dim Src as range
set src = nothing
on error resume next
set src = application.inputbox(....)
on error goto 0

if src is nothing then
'user hit cancel
exit sub '????
end if

....
 
Top