+ Reply to Thread
Results 1 to 6 of 6

ByRef Argument Error With Worksheet Exists Code

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    ByRef Argument Error With Worksheet Exists Code

    I am using this function to determine whether a worksheet exists in a workbook.

    Please Login or Register  to view this content.
    I call the function with this code ...

    Please Login or Register  to view this content.
    The worksheet (WSName) should exist in a second open workbook (wb_pstaff), but I'm getting an error in the calling code highlighted in red. ("ByRef Argument type mismatch").

    Can anyone advise what I need to do to get things working properly?

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: ByRef Argument Error With Worksheet Exists Code

    The variables must be the same data types when ByRef , so either
    in your sub
    Please Login or Register  to view this content.
    or function
    Please Login or Register  to view this content.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,351

    Re: ByRef Argument Error With Worksheet Exists Code

    First line in your sub.
    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.

  4. #4
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: ByRef Argument Error With Worksheet Exists Code

    Thank you both! :-)

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,351

    Re: ByRef Argument Error With Worksheet Exists Code

    You're welcome and thanks for rep+.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: ByRef Argument Error With Worksheet Exists Code

    Thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as 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. [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] Function ByRef Argument Error
    By cocacrave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-25-2015, 06:39 AM
  4. [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
  5. [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
  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. [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