When and Why to use Set X = Y

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using XL 2003

Noticed different techniques to "energize" a variable, ie:

X = Y+2

Set X = Y.Z

Could someone please explain or point me to an explanation of these
different techniques.

I do realize that they are not the same but I do not know why and when to
use them.

TIA Dennis
 
Set is used when creating an object variable, such as a worksheet or a
range, e.g.

Set mySheet = Activesheet
or
Set myRange = Activesheet.Range("A1:A10")

you can then manipulate this object in your code.

The other form just sets that variable to the value.
 
Thanks Bob

Bob Phillips said:
Set is used when creating an object variable, such as a worksheet or a
range, e.g.

Set mySheet = Activesheet
or
Set myRange = Activesheet.Range("A1:A10")

you can then manipulate this object in your code.

The other form just sets that variable to the value.

--

HTH

RP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top