+ Reply to Thread
Results 1 to 10 of 10

Application.WorksheetFunction.Match error

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Application.WorksheetFunction.Match error

    I get this error at
    Please Login or Register  to view this content.
    What is wrong with this line?


    Runtime error '1004'
    Unable to get the Match property of the WorkSheetFunction class at

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Application.WorksheetFunction.Match error

    Deniouz,

    Unless you have defined "ColumnA" as a defined cell or value somewhere else, the Code is not defining what to find within the "rng", (E.g TargetRow = WorksheetFunction.Match(Range("D2").Value, rng, 0)

    If you just want the next free row ("n"):

    With ActiveSheet
    n = .Cells(.Rows.Count, "A").End(xlUp).Row+1
    end with


    Ochimus
    Last edited by Ochimus; 12-04-2020 at 12:52 PM.

  3. #3
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Re: Application.WorksheetFunction.Match error

    Hello Ochimus. My ColumnA is the name of the combobox. How should I get the value from the combobox to be used in the match application?
    Last edited by Deniouz; 12-05-2020 at 11:26 AM.

  4. #4
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: Application.WorksheetFunction.Match error

    Assuming ColumnA is a value (whatever's been chosen in the list box - it should be if the listbox is an activeX listbox) then if the value's not to be found in rng then using
    Please Login or Register  to view this content.
    [note that the line above does NOT contain WorksheetFunction]
    will not throw an exception; instead TargetRow will contain an error. So then all you need to do is check if it contains an error:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Re: Application.WorksheetFunction.Match error

    It doesn't work. I get the error "method range of object worksheet failed. I think it has something to do with the ColumnA's row source. Currently it is empty. My TargetRow is supposed to target the exact row of the selected value in the combobox. How do I do that? I am trying to use the userform to edit values in the worksheets.
    Attached Files Attached Files
    Last edited by Deniouz; 12-05-2020 at 11:27 AM.

  6. #6
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Application.WorksheetFunction.Match error

    You also need to declare TargetRow as Variant in order for it to hold either Long or Error values. OP had declared it as Integer, which is almost always a mistake. Integer as VBA defines it is an outdated artifact of 16-bit computing, which went away by the mid-1990s.

  7. #7
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Re: Application.WorksheetFunction.Match error

    It still doesn't work. The Application.Match could run after setting as variant. However, it is not detecting the value in ColumnA. By the way, the table is a listobject. Did I do something wrong?

  8. #8
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Application.WorksheetFunction.Match error

    Try this. Supplement as needed with declarations and variable initializations you didn't include in your original code fragment.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Re: Application.WorksheetFunction.Match error

    It still does not work. No errors but the data keyed into the userform does not update the tables. The edit button is at sheet AAA.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-20-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    57

    Re: Application.WorksheetFunction.Match error

    Solved. Would have to use:

    Please Login or Register  to view this content.
    to convert the variant into integer

    and

    Please Login or Register  to view this content.
    to maintain the value from another userform
    Last edited by Deniouz; 12-06-2020 at 12:01 PM.

+ 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. Runtime error 1004 with Application.Worksheetfunction.Match
    By jeetkapadia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2017, 12:46 PM
  2. Application.WorksheetFunction.Match in VBA
    By karen53 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2014, 06:32 PM
  3. Application.worksheetfunction.match problem
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-28-2013, 08:47 AM
  4. Application.Worksheetfunction.match ERROR
    By Guido Meng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2013, 01:27 PM
  5. Overwriting Information with Application.WorksheetFunction.Match (Excel03)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2012, 08:36 AM
  6. Application.WorksheetFunction.Match
    By TK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2005, 05:05 PM
  7. Application.WorksheetFunction.Match problem
    By Carl Brehm in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2005, 11:06 AM

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