Results 1 to 17 of 17

GetMatch plus VBA Code to Extract Matched Numbers from 2 Single Cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    GetMatch plus VBA Code to Extract Matched Numbers from 2 Single Cells

    Hi, This David

    Please i need some help on GetMatch Formula and the VBA Macro..

    Here is the Problem:

    I have First Group of Number is In Cell C6 -> 28-17-20-32-21-18-25-40-50-60
    the Second Group Of Numbers is In Cell C9 -> 18-19-20-21-22-23-24-40-50-60

    i Need to Extract The Numbers that Match in the 2 Groups (20 21 18 40 50 60) and copy In Cell F6


    Please i need a Correction

    I Inserted the Following VBA Code :


    Function GetMatch(LookFor, LookIn)
        GetMatch = ""
        StartPos = 1
        For i = 1 To Len(LookFor)
            If Mid(LookFor, i, 1) = "-" Then
                ThisStr = Mid(LookFor, StartPos, (i - StartPos))
                If InStr(LookIn, ThisStr) > 0 Then
                    GetMatch = GetMatch & ThisStr & ", "
                End If
                StartPos = i + 1
            End If
        Next i
        ThisStr = Mid(LookFor, StartPos, (i - StartPos))
        If InStr(LookIn, ThisStr) > 0 Then
           GetMatch = GetMatch & ThisStr & ", "
        End If
    
        If Len(GetMatch) > 3 Then
            GetMatch = Left(GetMatch, Len(GetMatch) - 2)
        End If
    
    End Function

    And in Cell F6 (where i need the result) I Copy the following Formula :


     =GetMatch(C6,C9)


    Then when I Run the sheet i got i Error message :

    Please i need some expert to revise my mistake and tell me what is wrong....



    Thanks !!!
    Attached Files Attached Files
    Last edited by david gonzalez; 02-17-2013 at 10:40 PM. Reason: Change Title (i think is a Rule Violation) I Apologise

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