+ Reply to Thread
Results 1 to 5 of 5

Worksheetfunction.Match Issue

  1. #1
    Registered User
    Join Date
    10-29-2009
    Location
    NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Worksheetfunction.Match Issue

    Hi,

    I'm creating a UDF in which I use WorksheetFunction.Match.

    The Range I want to use is the first column of the user specified range.

    I achieve this as follows (I am only including the relevant part of the function for simplicity's sake):

    Please Login or Register  to view this content.
    Does anyone know why that line does not work? Note that when I removed the sheet name it worked fine (as long as the lookup range was in the same sheet as the cell with the function)
    Last edited by DonkeyOte; 11-01-2009 at 04:13 AM. Reason: tags added

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Worksheetfunction.Match Issue

    Welcome to the forum,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Worksheetfunction.Match Issue

    Hi DAA

    Try:

    Please Login or Register  to view this content.
    Don't forget the code tags around the code.


    Remarks:

    A -
    In your code

    Please Login or Register  to view this content.
    you have a syntax error. In the instruction Range(Range(),Range()) you are not allowed to mix ranges from different worksheets. In your code the part in blue refers to the worksheet DSheet while the inside, the part in red refers to the active sheet. This is a syntax error.

    B -

    In the line

    Please Login or Register  to view this content.
    you should correct 2 things

    1 - there are more than 32K rows even before excel 2007, so instead of defining the variables as Integer it's better to define theam as Long

    2 - in vba you must declare the type for each variable. In your line you are declaring RCol as Integer and you are not specifying the type for the other variables and so vba defines them as Variant. It should be


    Please Login or Register  to view this content.

    HTH

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Worksheetfunction.Match Issue

    DAA, on this occasion I have added the CODE tags for you - going forward please ensure you use them appropriately.

    lecxe, as valued as your posts are I would ask that you still comply with the rules of this forum - more specifically rule 7 (to paraphrase):

    Do not post a reply to a thread where a moderator has requested an action that has not been complied with e.g Title change or Code tags...etc
    TIA for your co-operation.
    D.O

  5. #5
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Worksheetfunction.Match Issue

    Hi D. O.

    I'm sorry, I was not aware of that rule. I should have read the rules more carefully, which I will do now.

    Thank you
    lecxe

+ 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