ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   question in VB codes (https://www.excelbanter.com/excel-discussion-misc-queries/158968-question-vbulletin-codes.html)

peyman

question in VB codes
 
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

Jim Thomlinson

question in VB codes
 
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.
--
HTH...

Jim Thomlinson


"peyman" wrote:

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



All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com