+ Reply to Thread
Results 1 to 7 of 7

ByRef Argument Type Mismatch Error

  1. #1
    Registered User
    Join Date
    05-29-2017
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010
    Posts
    19

    ByRef Argument Type Mismatch Error

    The error occurs on this line (I know that because my debug statement isn't being reached):

    Please Login or Register  to view this content.
    The following code is trying to invoke this line (variable ss is defined as an integer):

    Please Login or Register  to view this content.
    The function is expecting a string which is being passed, and returning an integer so I don't understand why I'm getting the mismatch error.

    Any ideas??

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: ByRef Argument Type Mismatch Error

    use Byval instead
    Function strengthSchedule(ByVal team As String) As Integer

  3. #3
    Registered User
    Join Date
    05-29-2017
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: ByRef Argument Type Mismatch Error

    Thanks AB33, this appears to have worked.

    I still don't understand why though. I realise that I was passing by reference (default) which means that the variable could be altered. But I was still passing a string which was being expected??

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: ByRef Argument Type Mismatch Error

    Did you declare homeTeam as String somewhere? If not, it was a Variant and therefore the type did not match the required argument type.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    05-29-2017
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: ByRef Argument Type Mismatch Error

    I think it was declared as string. Anyway I used byVal so it now works, thx

  6. #6
    Registered User
    Join Date
    05-29-2017
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: ByRef Argument Type Mismatch Error

    Pls could someone let me know how I mark this as solved, thx.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: ByRef Argument Type Mismatch Error

    It couldn't have been declared as String if you had that error.

    Click the Thread Tools dropdown at the top and then Mark thread solved.

+ 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 argument type mismatch error in function
    By Aphis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2015, 05:46 AM
  2. ByRef argument type mismatch
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2015, 11:23 AM
  3. [SOLVED] ByRef argument type mismatch
    By Lloyd Blankfein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-06-2012, 07:26 AM
  4. [SOLVED] ByRef argument type mismatch / Passing array as a function argument
    By pzling in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2012, 06:23 PM
  5. Byref argument type mismatch
    By ref in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2012, 06:17 AM
  6. Error passing element of string array get ByRef argument type mismatch
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-17-2011, 02:59 PM
  7. ByRef argument type mismatch error?
    By sermest in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2005, 02:05 PM

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