+ Reply to Thread
Results 1 to 4 of 4

When to use 'Set'

  1. #1
    Registered User
    Join Date
    09-06-2004
    Posts
    37

    When to use 'Set'

    Noob question time.

    I've noticed looking through here that sometimes 'Set' is used with a variable and other times it isn't. Is there a proper time and place to use 'Set'? When should I use/not use it?

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    In Visual Basic Editor
    Type Set then press F1 to get full details of the Set command

    Set - Assigns an object reference to a variable.

    example - assign a worksheet to a varaible

    set wS = Workbook("Book1").Sheets("Sheet1")

    allows you to refer to (work with) the worksheet directly

    eg ws.Range("a1")

    You will also need to understand what an Object is.

    In Visual Basic Editor - Type Object then press F1 to get full details of the Set command

    Object variables are stored as 32-bit (4-byte) addresses that refer to objects. Using the Set statement, a variable declared as an Object can have any object reference assigned to it.

  3. #3
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by Mark K
    Noob question time.

    I've noticed looking through here that sometimes 'Set' is used with a variable and other times it isn't. Is there a proper time and place to use 'Set'? When should I use/not use it?
    Hi Mark,

    Here is some additional info.

    http://www.excelforum.com/showthread.php?t=572376
    Last edited by Desert Piranha; 08-31-2006 at 01:49 PM. Reason: Spelling
    Thx
    Dave
    "The game is afoot Watson"

  4. #4
    Registered User
    Join Date
    09-06-2004
    Posts
    37
    Thanks, will look into them.

+ 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