+ Reply to Thread
Results 1 to 3 of 3

Error 2042 for application.match

  1. #1
    Forum Contributor
    Join Date
    07-22-2013
    Location
    Sibiu
    MS-Off Ver
    Excel 2007
    Posts
    114

    Error 2042 for application.match

    Please Login or Register  to view this content.
    It keeps giving me an error 2042 even if the value from b2 exists in Range("b:b") from 2nd sheet.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Error 2042 for application.match

    Hi a.hudrea,

    My version of Excel (2003) is very picky about data types when using Application.Match. This includes how you define the data on the spreadsheet, and how you define the values in VBA. Using Variant type, I duplicated your problem almost every time.

    The following test code may point you in the right direction.
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    Lewis

  3. #3
    Forum Contributor
    Join Date
    07-22-2013
    Location
    Sibiu
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Error 2042 for application.match

    Thanks you so much for the help, and thank you for taking the time to explain everything. 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. Error 2042 on Application.Match formula
    By krazyhype19 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-05-2015, 03:25 AM
  2. [SOLVED] Error 2042 using Application.Match to add item and update combobox list
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2013, 07:55 AM
  3. [SOLVED] Application.Match returns Error 2042 whene text absolutely does exist?
    By Rhudi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 04:21 PM
  4. Error 2042 with Application.Match
    By mgurren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 02:15 AM
  5. [SOLVED] Error 2042
    By GreenTee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 12:27 AM
  6. [SOLVED] Error 2042 with application.vlookup for date
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2013, 03:57 AM
  7. Error 2042
    By magix in forum Excel General
    Replies: 3
    Last Post: 12-12-2005, 08:20 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