set in vba?

dani1

Board Regular
Joined
Mar 23, 2010
Messages
90
hi ppl,

actually i wanted to know wat does "SET" do in vba?can anyone explain this with example?
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

You use Set when you want to assign an object reference to a variable eg:

Code:
Dim rng As Range
 
Set rng = Range("A1:A100")  'object reference

You use Let (or omit it altogether) when assigning a simple scalar value to a variable eg:

Code:
Dim lng As Long
 
Let lng = 100
 
'equiavlent to:
 
lng = 100
 

Watch MrExcel Video

Forum statistics

Threads
1,108,976
Messages
5,526,009
Members
409,675
Latest member
audeser

This Week's Hot Topics

Top