Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Error Not Displaying, Instead macro just ends

I have this code which runs, it encounters an error, then the program just
stops. It doesn't give me any messages. I had to use On error goto ErrH,
ErrH: Debug.Print Err to find out there was an Error. The error was 424,
Object undefined. I even put On error goto 0 before the code, but it still
doesn't display a error message for me.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Error Not Displaying, Instead macro just ends

Might help if you posted (all) the code

Regards

Trevor


"J@Y" wrote in message
...
I have this code which runs, it encounters an error, then the program just
stops. It doesn't give me any messages. I had to use On error goto ErrH,
ErrH: Debug.Print Err to find out there was an Error. The error was 424,
Object undefined. I even put On error goto 0 before the code, but it still
doesn't display a error message for me.



  #3   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Error Not Displaying, Instead macro just ends

Apparently the code causing problems was the following:

If Not Cel2 is Nothing then
.......
endif

Cel2 was Uninitialized. I only had Public Cel2 in the beginning. However I
have Option Explicit, so how come no error came of this?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Error Not Displaying, Instead macro just ends

As far as I know, "Public Cel2" would be equivalent to "Dim Cel2 as
Variant".

Hence the Option Explicit would have no complaint.

If you haven't initialised it, it would contain nothing so it would execute
the code.

Regards

Trevor


"J@Y" wrote in message
...
Apparently the code causing problems was the following:

If Not Cel2 is Nothing then
......
endif

Cel2 was Uninitialized. I only had Public Cel2 in the beginning. However I
have Option Explicit, so how come no error came of this?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error Not Displaying, Instead macro just ends

If you used:

Public Cel2 as range
'or even
'Public cel2 as object

Then you could check to see if that range object (or any object) is nothing
with:

if Not (cel2 is nothing) then



But using
Public Cel2 'as Variant
then cel2 would be empty

so you'd use:
if cel2 = empty then

But it's much better to declare your variables with the correct type (As Range,
As Long, As Worksheet, ...)

Because if you assign a range to that variable:

dim cel2 as variant
set cel2 = activesheet.range("a1")
if cel2 = empty then

would be testing to see if the value of the cell is empty.





J@Y wrote:

Apparently the code causing problems was the following:

If Not Cel2 is Nothing then
......
endif

Cel2 was Uninitialized. I only had Public Cel2 in the beginning. However I
have Option Explicit, so how come no error came of this?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Error Not Displaying, Instead macro just ends

That's what I thought. If it was nothing, then the code should continue. But
the whole macro stops at the "If Not Cel2 is Nothing then" line, which is
what is confusing me.

"Trevor Shuttleworth" wrote:

As far as I know, "Public Cel2" would be equivalent to "Dim Cel2 as
Variant".

Hence the Option Explicit would have no complaint.

If you haven't initialised it, it would contain nothing so it would execute
the code.

Regards

Trevor


"J@Y" wrote in message
...
Apparently the code causing problems was the following:

If Not Cel2 is Nothing then
......
endif

Cel2 was Uninitialized. I only had Public Cel2 in the beginning. However I
have Option Explicit, so how come no error came of this?




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
Execution ends without error message in middle of program Richard J. Snee Excel Programming 3 June 11th 07 05:37 AM
Can VBA tell a user a macro is running until it ends? weisenb_stev Excel Programming 3 June 22nd 06 08:23 PM
update links when Macro ends Gato Excel Programming 0 February 21st 06 07:09 PM
PasteSpecial xlPasteFormats ends macro itarnak Excel Programming 4 October 12th 05 02:44 PM
Code ends subroutine in error Mike[_58_] Excel Programming 3 November 20th 03 12:54 AM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"