+ Reply to Thread
Results 1 to 4 of 4

Are variants automatically passed ByRef?

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Are variants automatically passed ByRef?

    Hello,

    My understanding of VBA is that values are automatically passed to functions by value, not by reference. However, in the following code, when I modify ctrRole, the data which I passed to that parameter also gets modified leading me to believe that the variant type is passed ByRef by default. Any input would be appreciated. Thank you!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Are variants automatically passed ByRef?

    VBA default is ByRef. VB.Net is ByVal, though it's often useful to specify this explicitly - have a read here: http://www.cpearson.com/excel/byrefbyval.aspx

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Are variants automatically passed ByRef?

    By default arguments are passed ByRef.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Are variants automatically passed ByRef?

    Alright, good to know! That is why i love this forum. Thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Byref issues
    By vincenzo345 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-12-2013, 10:19 AM
  2. [SOLVED] ByRef argument type mismatch
    By Lloyd Blankfein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-06-2012, 07:26 AM
  3. ByRef problem in VBA
    By itsmarkdavies in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2007, 09:45 AM
  4. ByRef Cancel in event module
    By Doug Glancy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2005, 05:05 PM
  5. [SOLVED] How do I automatically show passed dates in red in Excel, please
    By Jimbob in forum Excel General
    Replies: 4
    Last Post: 07-01-2005, 10:05 AM

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