+ Reply to Thread
Results 1 to 4 of 4

If Not c Is Nothing Then

  1. #1
    iron
    Guest

    If Not c Is Nothing Then

    I've been around Excel for a number of years, but am new to VBA. I recently
    came across the code "If Not c Is Nothing Then". Could someone explain to me
    what this means...the double negative throws me.

  2. #2
    Jim Thomlinson
    Guest

    RE: If Not c Is Nothing Then

    c is going to be an object of some sort. One possiblity is c is going to be a
    range object (a range is a cell or group of cells on one sheet. Being that c
    is an object until it has been "Set" to something it will be "Nothing". Once
    it is set then it essentially points at a range. One common use for checking
    for nothing is when you do a "Find" operation. If nothing is found then the
    range object is still nothing. Now you check the c to determine if it is
    nothing, or if it points to the found cell.
    --
    HTH...

    Jim Thomlinson


    "iron" wrote:

    > I've been around Excel for a number of years, but am new to VBA. I recently
    > came across the code "If Not c Is Nothing Then". Could someone explain to me
    > what this means...the double negative throws me.


  3. #3
    Jim Cone
    Guest

    Re: If Not c Is Nothing Then

    If True Then '(will execute)
    If False Then '(will not execute)

    c is nothing evaluates to either True of False
    c would be an object variable.
    c will be nothing until it has been assigned an object.
    c is nothing = True if no object is assigned to it.
    c is nothing = False if has been assigned an object.

    "Not" reverses a Boolean designation.
    Not True = False
    Not False = True

    Not c is nothing returns either True or False and the
    "If" statement executes if c has been assigned to an object.
    --
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware



    "iron" <iron@discussions.microsoft.com>
    wrote in message
    I've been around Excel for a number of years, but am new to VBA.
    I recently came across the code "If Not c Is Nothing Then".
    Could someone explain to me what this means...the double negative throws me.

  4. #4
    Bob Phillips
    Guest

    Re: If Not c Is Nothing Then

    It is the same as

    If c Is Something Then

    which unfortunately is not valid code.

    It is testing if the previous action was successful in creating an object,
    or whether it failed.

    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    "iron" <iron@discussions.microsoft.com> wrote in message
    news:00D3FA8E-8117-4671-9B46-4D7E9B2D1E37@microsoft.com...
    > I've been around Excel for a number of years, but am new to VBA. I

    recently
    > came across the code "If Not c Is Nothing Then". Could someone explain to

    me
    > what this means...the double negative throws me.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1