+ Reply to Thread
Results 1 to 4 of 4

Function with 2 variables

  1. #1
    Registered User
    Join Date
    06-09-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Function with 2 variables

    Hi,

    I just got started with VBA and I think
    Could you help me out with this one?

    I have a function which I originally intented to have 1 varible.

    Please Login or Register  to view this content.
    This works perfect, but when I change one line adding a string to the function [CODE]Call func1(Row, 2)CODE] I get an error message byref argument type mismatch. In the function I have already declared that I am using 2 Integers. What can I do about this?

    Cheers
    Pete

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Function with 2 variables

    It would be interesting to see your codes for the function funcl(var1,var2) you call in this macro.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    06-09-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Function with 2 variables

    The function starts with
    Please Login or Register  to view this content.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Function with 2 variables

    your function define the first parameter as an INTEGER but you forgot to DIM the variable ROW which is by default a Variant. As you pass your parameter ByRef, you need to use the EXACT same data type at both place.

    Add this statement in your "firstsub" procedure:
    Please Login or Register  to view this content.

+ 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