+ Reply to Thread
Results 1 to 3 of 3

Error 2042-how I was told to do it.

  1. #1
    papa jonah
    Guest

    Error 2042-how I was told to do it.

    I am trying to use the match function within vba without using a cell.
    The following is how I was told to do it. I am trying to match the
    value of begbase (which is "10/1/97" in this case).

    Dim sb As Variant

    sb = Application.Match(begbase, Range("a2:a" & causerows))

    What I get is Error 2042. I don't know what that is. Can some one
    either tell me what it is, or better yet, how to solve the problem?

    TIA


  2. #2
    JE McGimpsey
    Guest

    re: Error 2042-how I was told to do it.

    Error 2042 means that the Match was not found. It's equivalent to
    returning #N/A when called from the worksheet.

    Since you're not using the match type argument, it means a value greater
    than sb was found before sb, if sb exists in the target range.


    In article <[email protected]>,
    "papa jonah" <[email protected]> wrote:

    > I am trying to use the match function within vba without using a cell.
    > The following is how I was told to do it. I am trying to match the
    > value of begbase (which is "10/1/97" in this case).
    >
    > Dim sb As Variant
    >
    > sb = Application.Match(begbase, Range("a2:a" & causerows))
    >
    > What I get is Error 2042. I don't know what that is. Can some one
    > either tell me what it is, or better yet, how to solve the problem?
    >
    > TIA


  3. #3
    Dave Peterson
    Guest

    re: Error 2042-how I was told to do it.

    Are you trying to find an exact match?

    If yes:

    dim SB as variant
    sb = application.match(begbase,range("a2:a" & causerows),0))
    if iserror(sb) then
    'not found
    else
    'found
    end if

    Sometimes with dates, this works better:
    sb = application.match(clng(begbase),range("a2:a" & causerows),0))



    papa jonah wrote:
    >
    > I am trying to use the match function within vba without using a cell.
    > The following is how I was told to do it. I am trying to match the
    > value of begbase (which is "10/1/97" in this case).
    >
    > Dim sb As Variant
    >
    > sb = Application.Match(begbase, Range("a2:a" & causerows))
    >
    > What I get is Error 2042. I don't know what that is. Can some one
    > either tell me what it is, or better yet, how to solve the problem?
    >
    > TIA


    --

    Dave Peterson

+ 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