View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
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