Results 1 to 6 of 6

Runtime Error 1004 : Unable to get the Match Property

Threaded View

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    41

    Runtime Error 1004 : Unable to get the Match Property

    We had a macro written 4 or 5 years ago that took the attached xlsx and changed the data around into a more readable format.

    Where the script seems to get stuck on is for example Column A has a part number without letters in it. For example A:226 - A:255 (Theres more if you page down)

    If I remove these cells the script works but seems to only get stuck on these types of part numbers.

    Could anyone help me find the problem?


    Sub test()
    
     Dim strTargetFile As String
     Application.DisplayAlerts = False
     strTargetFile = "*.xml"
     Workbooks.OpenXML Filename:=strTargetFile, LoadOption:=xlXmlLoadImportToList
     Application.DisplayAlerts = True
     
    Columns(2).EntireColumn.Delete
    Columns(2).EntireColumn.Delete
    Columns(2).EntireColumn.Delete
    Columns(2).EntireColumn.Delete
    Columns(2).EntireColumn.Delete
    Columns(4).EntireColumn.Delete
    
    Dim ws, ws2, ws3 As Worksheet, lr%, celval$, destcol%, destrow%
    
    Set ws = ActiveSheet
    Set ws2 = Worksheets.Add
    Set ws3 = Worksheets.Add
    
    ws.Cells.Copy
    ws2.Range("A1").PasteSpecial xlPasteValues, xlNone
    Application.CutCopyMode = False
    
    lr = ws2.Range("C65536").End(xlUp).Row
    
    ws2.Sort.SortFields.Add Key:=Range("B2:B" & lr), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ws2.Sort
            .SetRange Range("A1:C" & lr)
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    
    For Each cell In ws2.Range("B2:B" & lr)
    If cell.Value <> celval Then
    celval = cell.Value
    ws3.Cells(1, ws3.Columns.Count).End(xlToLeft).Offset(0, 1).Value = celval
    End If
    
    If WorksheetFunction.CountIf(ws3.Range("A:A"), cell.Offset(0, -1).Value) = 0 Then ws3.Range("A65536").End(xlUp).Offset(1, 0).Value = cell.Offset(0, -1).Value
    
    destrow = WorksheetFunction.Match(cell.Offset(0, -1).Value, ws3.Range("A:A"), 0)
    destcol = ws3.Rows("1:1").Find(What:=cell.Value, After:=Cells(1, 1), LookIn:=xlFormulas, LookAt:=xlWhole, MatchCase:=False).Column
    Cells(destrow, destcol).Value = cell.Offset(0, 1).Value
    Next cell
    ws3.Rows("1:1").NumberFormat = "Mmm/dd/yyyy"
    
    Application.DisplayAlerts = False
    ws2.Delete
    Application.DisplayAlerts = True
    Application.DisplayAlerts = False
    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Delete
    Application.DisplayAlerts = True
    ActiveSheet.Name = "830 Data"
    
    End Sub
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by agengler11; 05-21-2018 at 05:54 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro working in windows machine but not working in MAC
    By amitmodi_mrt in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 5
    Last Post: 11-16-2017, 11:26 AM
  2. [SOLVED] Macro working in windows machine but not working in MAC
    By amitmodi_mrt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2017, 02:12 PM
  3. Copied working macro to new workbook, but no longer working
    By twisted31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2017, 06:17 PM
  4. [SOLVED] Macro working perfectly on MS office x86 but not working on x64
    By alexgoaga in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-26-2017, 05:04 AM
  5. Well working simple macro now not working-open folder
    By jomili in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 07-05-2017, 08:24 AM
  6. [SOLVED] help index and match macro not working but formula working??
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2016, 06:37 AM
  7. Hide Columns Macro - Working on Windows not working on Mac OSX
    By bcadar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2016, 09:05 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