ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   EXIT SUB UPON VBCANCEL (https://www.excelbanter.com/excel-discussion-misc-queries/227161-exit-sub-upon-vbcancel.html)

FARAZ QURESHI

EXIT SUB UPON VBCANCEL
 
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


Daniel.C[_3_]

EXIT SUB UPON VBCANCEL
 
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


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




Dave Peterson

EXIT SUB UPON VBCANCEL
 
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

....



FARAZ QURESHI wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com