what does the operator ":=" mean?

  • Thread starter Thread starter Michael/what does the operator := mean
  • Start date Start date
M

Michael/what does the operator := mean

in Office VB code:
what does the operator ":=" mean?

example:
Worksheets("Daily Targets").Range("A5:N5").Copy _
Destination:=Worksheets("Daily Targets").Range("A" & CStr(rowCounter))

i wrote this code but i copied the it from the HELP, & then i changed the
names & variables. BUT, i'd like to understand what does the operator := is
filling for, is it an object assigning or what ... i'm not sure ??!!!

regards,
Michael
 
Probably the easiest way to explain it is that the colon (:) tells VBA that
it is not assigninng a variable. In other words if you entered this
statement:

Destination = Range("A1")

, then VBA would treat Destination as a variable and unless you put Set in
front of Destination it would give you an error message.

But with the colon and equal sign (:=) VBA knows that Destination is a
parameter of the Copy and Paste method and not a variable assignment.
 
Hi,

It's the syntax for named arguments.

From help file:
A named argument consists of an argument name followed by a colon and an
equal sign (:=), followed by the argument value.

For more details search help using "Understanding Named and Optional
Arguments"

Cheers
Andy
 
Just to confuse matters further. Using named arguments allows you to just
enter the non-default arguments for a command and enter them in any order
rather than having to enter something for every possible argument and to have
to do it in a particular order. The := tells the VBA engine that what
follows is a value to be used as the specific argument indicated by the entry
 

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