+ Reply to Thread
Results 1 to 4 of 4

Vba - := ????

  1. #1
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Question Vba - := ????

    Group,
    I often see examples of VBA code using the := (colon equal). What is this and what is it typically used for? It appears to be some form of assignment.

    Thank you in advance........

    Tony

  2. #2
    Registered User
    Join Date
    07-25-2005
    Posts
    62
    It's mostly to make things easier with argument lists
    Example:
    You want to open a workbook from a macro and have it go in the recently used file list. The syntax for the open method is:

    expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMRU)

    You need to set AddToMRU to true. You could go through and re-enter all the defaults for the other arguments like Workbooks.Open("file.xls", false, false,....., true) and you have to go figure out what all needs to go there or you could type:

    Workbooks.Open "file.xls", AddToMRU := true

    Saves a lot of typing.

  3. #3
    Bernie Deitrick
    Guest

    Re: Vba - := ????

    Tony,

    For many methods, named parameters are used, and the := is used to assign a value to the named
    parameter. For example, you could use either of these with the find method:

    Dim c As Range
    Set c = Cells.Find(What:="myFindString", LookIn:=xlValues, lookAt:=xlWhole)
    This example leaves out the After:= parameter (but doesn't require a space holder for it).

    Set c = Cells.Find("myFindString", , , xlWhole)
    This one leaves out the parameter names (and skips the After and LookIn parameters) but requires
    space holders (the commas).

    HTH,
    Bernie
    MS Excel MVP


    "ajocius" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Group,
    > I often see examples of VBA code using the := (colon equal). What
    > is this and what is it typically used for? It appears to be some form
    > of assignment.
    >
    > Thank you in advance........
    >
    > Tony
    >
    >
    > --
    > ajocius
    > ------------------------------------------------------------------------
    > ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
    > View this thread: http://www.excelforum.com/showthread...hreadid=392118
    >




  4. #4
    Tom Ogilvy
    Guest

    Re: Vba - := ????

    Not quite as bad as you make out

    >expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
    >WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter,
    >Editable, Notify, Converter, AddToMRU)


    >You need to set AddToMRU to true. You could go through and re-enter

    all the defaults for the other arguments like

    or just
    Workbooks.Open("file.xls",,,,,,,,,,,,true)

    but using named arguments still saves some typing in many cases.

    --
    Regards,
    Tom Ogilvy

    "TommySzalapski"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > It's mostly to make things easier with argument lists
    > Example:
    > You want to open a workbook from a macro and have it go in the recently
    > used file list. The syntax for the open method is:
    >
    > expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
    > WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter,
    > Editable, Notify, Converter, AddToMRU)
    >
    > You need to set AddToMRU to true. You could go through and re-enter
    > all the defaults for the other arguments like
    > Workbooks.Open("file.xls", false, false,....., true) and you have to go
    > figure out what all needs to go there or you could type:
    >
    > Workbooks.Open "file.xls", AddToMRU := true
    >
    > Saves a lot of typing.
    >
    >
    > --
    > TommySzalapski
    > ------------------------------------------------------------------------
    > TommySzalapski's Profile:

    http://www.excelforum.com/member.php...o&userid=25561
    > View this thread: http://www.excelforum.com/showthread...hreadid=392118
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1