Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Execution ends without error message in middle of program | Excel Programming | |||
Can VBA tell a user a macro is running until it ends? | Excel Programming | |||
update links when Macro ends | Excel Programming | |||
PasteSpecial xlPasteFormats ends macro | Excel Programming | |||
Code ends subroutine in error | Excel Programming |