question in VB codes

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

Guest

hi,
is there any difference between these two codes?
for example:
set curCell=sheets("sheet1").cells(1,3)
and
curCell=sheets("sheet1").cells(1,3)
I'd like to know why sometimes "set" is used at the beginning of codes?
thanks
 
Those two statements are very different. The first statement creates a range
object that references cell C1. The second statement fills a variable with
the contents of cell C1.

The Set statement is used to create or modify objects. Basically telling
your sytem to point to an object like a range or a worksheet or workbook.
With that reference I can access all of the properties and methods of that
object.

Your second statement fills a variable with the contents of the cell. By
default a cell returns its value unless you specify otherwise.
 
Back
Top