+ Reply to Thread
Results 1 to 4 of 4

Thread: Run-time error 1004: Unable to get the Match property of the WorksheetFunction class

  1. #1
    Registered User
    Join Date
    06-09-2005
    Posts
    3

    Run-time error 1004: Unable to get the Match property of the WorksheetFunction class

    So I created this code for some dummy data and it worked seamlessly. Now that I've copied it to the real workbook I get an run-time error.

    I've looked at prior threads that have solved this problem and it doesn't seem to work for me.

    Could you help me out?
    Sub updateDept()
    
        Range("A1").EntireColumn.Insert (xlLeft)
    
        ICN_Offset = Application.WorksheetFunction.Match("ICN", Range("A1:Z1"), 0) - 1
        KO_Offset = Application.WorksheetFunction.Match("KO", Range("A1:Z1"), 0) - 1
        
        Range("A2", Range("B2").End(xlDown).Offset(0, -1)).FormulaR1C1 = _
                "=RC[" & ICN_Offset & "]&RC[" & KO_Offset & "]"
                
        Range("A2").Select
        Do
        With Worksheets("All").Range("a1:a" & Worksheets("All").Range("B2").End(xlDown).Row)
        Set c = .Find(ActiveCell.Value, LookIn:=xlValues)
        If Not c Is Nothing Then
            ActiveCell.Offset(0, 9).Value = "Rec"
            ActiveCell.EntireRow.Hidden = True
        End If
        ActiveCell.Offset(1, 0).Select
        End With
        Loop Until ActiveCell.Value = ""
      Range("A1").EntireColumn.Delete
      
    End Sub
    
    Sub prepAll()
    
        Application.ScreenUpdating = False
        Application.StatusBar = "Processing"
        
    
        Range("A1").EntireColumn.Insert (xlLeft)
        
        ICN_Offset = WorksheetFunction.Match("ICN", Range("A1:Z1"), 0) - 1
        KO_Offset = WorksheetFunction.Match("KO", Range("A1:Z1"), 0) - 1
       
        
        Range("A2", Range("B2").End(xlDown).Offset(0, -1)).FormulaR1C1 = _
                "=RC[" & ICN_Offset & "]&RC[" & KO_Offset & "]"
        
        ActiveSheet.Name = "All"
        
        
        For Each CodeSheet In ActiveWorkbook.Sheets
            If Not CodeSheet.Name = "All" Then
                CodeSheet.Activate
                Call updateDept
            End If
        Next CodeSheet
        Sheets("All").Select
        Range("A1").EntireColumn.Delete
        
        Application.ScreenUpdating = True
        Application.StatusBar = False
    End Sub

    maffmommie nqztiv
    I'm new to the game.
    HTML/PHP/MySQL/XML/Javascript

  2. #2
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,957

    Re: Run-time error 1004: Unable to get the Match property of the WorksheetFunction cl

    You're getting the run-time error because it can't find the value you're searching for, either:

    1. Double-check your ranges and values, to make sure you're looking for the right thing in the right place OR

    2. Put some error trapping in to deal with this OR

    3. Switch to using .FIND, which returns more manageable exceptions.

  3. #3
    Registered User
    Join Date
    06-09-2005
    Posts
    3

    Re: Run-time error 1004: Unable to get the Match property of the WorksheetFunction cl

    Well the value is definitely in the range...hmmm...

    How would I change it to .FIND? I just need to look in the header row on 1 particular sheet and match it with the header row of the another sheets
    Last edited by maffmommie; 08-13-2010 at 09:40 AM. Reason: more information

    maffmommie nqztiv
    I'm new to the game.
    HTML/PHP/MySQL/XML/Javascript

  4. #4
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,957

    Re: Run-time error 1004: Unable to get the Match property of the WorksheetFunction cl

    Is it in the range after you account for shifting the whole range one column right?

    Also you might want to specify somewhere in your code which workbook and sheet you're working with, as this may resolve some ambiguity.

+ 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.2.0