+ Reply to Thread
Results 1 to 3 of 3

Error 1004 Unable to get the Match property (and On Error Resume Next doesn't help!)

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Error 1004 Unable to get the Match property (and On Error Resume Next doesn't help!)

    Having an issue with VBA code that is trying to find a certain optional heading in row 1 (of a defined sheet in a separate file called DataSheet). I want to set an integer variable (JunkCol) to the column number of a specified heading ("Junk" in this example), or to a value of zero if the heading is not found. Code looks like this:
    Please Login or Register  to view this content.
    Problem: This normally works fine, but if the macro happens to run an error-handling routine (for another issue), then thereafter I seem to be getting "Error 1004 - Unable to get the Match property..." whenever any match statement fails to find the desired heading (in spite of the On Error Resume Next). My error handler does clear the previous error, and I've even inserted code right before the match statement to ensure that any previous errors are cleared:
    Please Login or Register  to view this content.
    Still no go; I still get the Error 1004 after the error handler runs. What's the problem? Why won't "On Error Resume Next" work, if any previous errors have been cleared?
    Again, this works fine until my error handler runs, then I start getting Error 1004 on every match that fails. By the way, my error handler (when a REQUIRED heading isn't found) just pops up a message, clears the error, and jumps to the next data file, like this:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,861

    Re: Error 1004 Unable to get the Match property (and On Error Resume Next doesn't help!)

    There are some cases where setting error handling to Resume Next is simple and effective, but I think that a good habit is to deal with error causing situations before an error occurs.

    the simple way in your case could be:
    Please Login or Register  to view this content.
    another option would be calling the built in function in application context (not worksheetfunction) and analyze if returned value is an error

    like:
    Please Login or Register  to view this content.
    To directly answer your question we probably shall see larger snippet of your code - probably error handling is not set to resume next because of other parts of the code - you tried to show us a part of it, but in my opinion it's not enough.
    Best Regards,

    Kaper

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

    Re: Error 1004 Unable to get the Match property (and On Error Resume Next doesn't help!)

    Index and Match drive me crazy and I don't use them unless I absolutely have to.

    Try something like the following using .find:
    Please Login or Register  to view this content.
    Lewis

+ 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] Error-1004 Unable to get Match Property of the worksheet Function Class
    By paradise2sr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-26-2019, 07:08 AM
  2. Runtime Error 1004 : Unable to get the Match Property
    By agengler11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2018, 11:59 AM
  3. runtime error 1004 unable to get match property
    By AAvcal71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2014, 03:10 PM
  4. [SOLVED] Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-11-2012, 10:42 AM
  5. Run-time error '1004': Unable to get the Match property of Worksheetfunction class
    By krish T in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2010, 10:04 PM
  6. Run-time error 1004: Unable to get the Match property of the WorksheetFunction class
    By maffmommie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2010, 09:32 AM
  7. run-time error '1004 Unable to get Match property of WorksheetFunction class
    By exl044 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2010, 02:23 AM

Tags for this Thread

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