+ Reply to Thread
Results 1 to 10 of 10

ByRef argument type missmatch error

  1. #1
    Registered User
    Join Date
    11-24-2019
    Location
    Denmark
    MS-Off Ver
    2019
    Posts
    10

    ByRef argument type missmatch error

    I am not very experienced in programming excel but using some books and examples from internet I can create what I need. Unfortunately I've met problem that I can't resolve. Below you can see the little portion of code (not mine taken from the book ) but for me it doesn't work. when I call function it popup with an error as in the topic.
    Anyone can help me with this issue? It is part of the program I would like to update range in one of workbook.names used in selection.validation. Range will be taken diferent file without opening it.

    -----------------------------------------------------------------

    Please Login or Register  to view this content.
    Last edited by Pepe Le Mokko; 11-24-2019 at 01:48 PM. Reason: Added code tags

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ByRef argument type missmatch error

    Your function is expecting a range object
    Please Login or Register  to view this content.
    But you are passing it a Variant
    Please Login or Register  to view this content.
    Change Variant to Range & you should be ok

  3. #3
    Registered User
    Join Date
    11-24-2019
    Location
    Denmark
    MS-Off Ver
    2019
    Posts
    10

    Re: ByRef argument type missmatch error

    Hi Fluff13,

    but the result of this function should be Variant, and the input should be Range, isn't it

    As I do understand

    Public Function LastInColumn(rngInput As Range) As Variant

    so I put A1 (Range) as an argument when call function

    and should get l as Variant

    Am I wrong?

    It complains about A1 as argument for the function

    error.png
    Last edited by Marecki; 11-24-2019 at 12:00 PM. Reason: add picture

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: ByRef argument type missmatch error

    You have to pass a range to the function.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ByRef argument type missmatch error

    Oops, didn't read it properly
    Please ignore post#2 it's complete rubbish.

  6. #6
    Registered User
    Join Date
    11-24-2019
    Location
    Denmark
    MS-Off Ver
    2019
    Posts
    10

    Re: ByRef argument type missmatch error

    Now it popup error Expected: List separator or ) in edition mode

    Attachment 651250

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: ByRef argument type missmatch error

    Works just fine.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-24-2019
    Location
    Denmark
    MS-Off Ver
    2019
    Posts
    10

    Re: ByRef argument type missmatch error

    well yours works just fine I can see now where I have done mistake I didn't type quotation marks
    Thanks for your help

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: ByRef argument type missmatch error

    @Marecki
    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: ByRef argument type missmatch error

    @ Marecki

    Glad to help and thanks for feedback.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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. [SOLVED] ByRef Argument Type Mismatch Error
    By ALEXJM in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-03-2017, 11:06 AM
  2. 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
  3. [SOLVED] "ByRef argument type mismatch error" trying to use my first UDF
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-23-2014, 08:46 PM
  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. 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
  6. "ByRef argument type mismatch" Error
    By Baapi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2005, 08:05 PM
  7. [SOLVED] 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