Difference in type between using and not using Set keyword

后端 未结 3 1810
情话喂你
情话喂你 2020-11-29 10:49

I just solved a problem I was having putting the \"Set\" keyword in a definition line but what I would like to know is \"why\" ?

Basically, I am doing this:

3条回答
  •  长情又很酷
    2020-11-29 11:08

    Set is used to assign a reference to an object, Let (or simple assignment) to assign the value of an object (if any)

      Dim a As Variant
      Set a = ActiveSheet.Cells(1)
      'TypeName(a) = Range, a now contains reference to the cell's range
      a = ActiveSheet.Cells(1)
      'TypeName(a) = Double or String, whatever is in the Cell, a contains the cell's value
    

提交回复
热议问题