+ Reply to Thread
Results 1 to 3 of 3

match not found - message

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-08-2005
    Location
    Silicon Valley, CA USA
    MS-Off Ver
    2013 - Using 64 bit system
    Posts
    275

    match not found - message

    Hi,
    I am working on XL database and have two codes for pulling data out from the main sheet on to sheet2 and another code to put it back after I update info.
    The 'replace' code seems to be having problem and keep giving me "match not found for row 2" message.
    Appreciate your help on this. Here is the code:

    Thank you.

    Sub replace()
    Dim ws As Worksheet
    Dim wsList As Worksheet
    Dim searchRng As Range
    
        Set wsList = Sheets("HajiList")
        Set searchRng = wsList.Columns(8)
    
        Set ws = Sheets("Sheet2")
        lastRow = ws.Cells(ws.Rows.Count, 8).End(xlUp).Row
        
        For i = lastRow To 2 Step -1
            'unique identifier is in column E
            myID = Range("E" & i)
            
            'find matching row number on MyList sheet
            matchRow = 0
            On Error Resume Next
            matchRow = Application.WorksheetFunction.Match(myID, searchRng, 0)
            If matchRow > 0 Then
                'we found a match
                ws.Rows(i).Copy Destination:=wsList.Range("A" & matchRow)
                ws.Rows(i).Delete
            Else
                MsgBox "Match not found for row " & i
            End If
        Next i
    
    End Sub
    Last edited by VBA Noob; 01-28-2008 at 04:02 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello jazbeth,

    If all the other rows are OK then I have to ask did you check the values when you get the error message? It could be there is no match.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    12-08-2005
    Location
    Silicon Valley, CA USA
    MS-Off Ver
    2013 - Using 64 bit system
    Posts
    275
    Hi Leith,

    thank you for responding. The error message is only "match not found for row no." it would give you row number.

    Thanks
    Jaz

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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