+ Reply to Thread
Results 1 to 9 of 9

Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Post Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    I keep getting a runtime error but I do not know why. It is giving me a Run-time error 1004 "Unable to get the Match property of the WorksheetFunction class." It highlights a variable that I try to define. I copy/pasted the match criteria, so I know it is accurate.

    Anyone have an idea of what's wrong?

    
    Dim i, i2, i3, i4, LR, lRow As Long, rngData As Range
    
    
        i1 = Application.WorksheetFunction.Match("MGR_NAME", Range("1:1"), 0)

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Which worksheet are you meant to be looking in?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    the name of the worksheet is called ("Mod")

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Does this work?
    
    Dim i, i2, i3, i4, LR, lRow As Long, rngData As Range
    
    
        i1 = Application.WorksheetFunction.Match("MGR_NAME",   Worksheets("Mod").Range("1:1"), 0)

  5. #5
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    Ok cool. If I had to declare a bunch of i variable from the same sheet, would it make more sense to use a "With...End With" statement?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    How would you use With for a variable?

  7. #7
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    Just to define them all at once:

    Dim i, i2, i3, i4, LR As Long, rngData As Range
    
    With Worksheets("MOD").Activate
    
        Set rngData = Range("A1").CurrentRegion
    
        i1 = Application.WorksheetFunction.Match("MGR_NAME", Range("1:1"), 0)
        i2 = Application.WorksheetFunction.Match("7060", Range("1:1"), 0)
        i3 = Application.WorksheetFunction.Match("7194", Range("1:1"), 0)
        i4 = Application.WorksheetFunction.Match("WORKOUT_TYPE", Range("1:1"), 0)
    
    End With

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    That won't work.


    Try this.
    Dim i, i2, i3, i4, LR As Long, rngData As Range
    
    With Worksheets("MOD")
    
        Set rngData = .Range("A1").CurrentRegion
    
        i1 = Application.WorksheetFunction.Match("MGR_NAME", .Range("1:1"), 0)
        i2 = Application.WorksheetFunction.Match("7060", .Range("1:1"), 0)
        i3 = Application.WorksheetFunction.Match("7194", .Range("1:1"), 0)
        i4 = Application.WorksheetFunction.Match("WORKOUT_TYPE", .Range("1:1"), 0)
    
    End With
    PS What's rngData for?

  9. #9
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Re: Run-time error 1004 - Unable to get the match property of WorksheetFucntion lass

    okkk so I'll just get rid of the .activate. The rngData was for something else that I was trying, but it doesnt seem necessary anymore. Thank you for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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