+ Reply to Thread
Results 1 to 5 of 5

"Set" command

  1. #1
    Forum Contributor
    Join Date
    03-27-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    290

    "Set" command

    Please Login or Register  to view this content.
    Why is it that the first command doesnt require "Set" however the second one does. I have tried the "descend" without the word set but it doesnt work... so why does that require Set yet the first line doesnt?

    thanks

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: "Set" command

    You mean by first this one
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    The first one is any varaible while the second is object varaible.
    When you assign object varaible to an object, you need to use set

    You could have used the full reference instead of with and with

    Put this line in front of every line which has a dote infront and delete the "With and end with"
    Please Login or Register  to view this content.
    Last edited by AB33; 10-25-2012 at 05:05 AM.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,508

    Re: "Set" command

    Because the first is "assigning" a value to a numeric variable and the second is "setting" the value of an *object* variable ... in this case, a range.

    You probably don't really need the set here; you could just use:

    Please Login or Register  to view this content.

    But, if you use it elsewhere, it could make the code shorter and easier to read.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    03-27-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: "Set" command

    thanks for the responses. Objects are treated differently to numerical values =) got it.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,508

    Re: "Set" command

    You're welcome. Thanks for the rep.

+ 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