Results 1 to 10 of 10

User Defined function for comparing 2 array and return approximate match

Threaded View

  1. #1
    Registered User
    Join Date
    05-05-2018
    Location
    Dubai, UAE
    MS-Off Ver
    2016
    Posts
    5

    User Defined function for comparing 2 array and return approximate match

    Hey, please help

    I need to compare 2 arra

    First having titles like:
    Manager-accounts
    Manager - Sales
    Officer - Accounts
    Officer - HR
    Supervisor-

    Second having (this is not set in stone)
    Manager
    Officer
    Supervisor
    etc.

    I want to compare the 2 array and then return the common term from the second array.
    Result needs to be

    Manager
    Manager
    Officer
    Officer
    Supervisor


    I tried this code in module

    Function StringMatch(ByVal sMaster As String, ByVal sSlave As String, Optional bMatchCase = False, Optional sDelimiter = " ") As String
    
    Dim asMast() As String, asSlav() As String
    Dim lWordLoop As Long
    Dim sTemp As String
    
    If Not bMatchCase Then
      sMaster = UCase(sMaster)
      sSlave = UCase(sSlave)
    End If
    
    asMast = Split(sMaster, sDelimiter)
    asSlav = Split(sSlave, sDelimiter)
    
    sTemp = ""
    
    For lWordLoop = LBound(asMast) To UBound(asMast)
      If Not IsError(Application.Match(asMast(lWordLoop), asSlav, 0)) Then
        sTemp = sTemp & asMast(lWordLoop) & sDelimiter
      End If
    Next lWordLoop
    
    If Len(sDelimiter) > 0 And Len(sTemp) > 0 Then
      sTemp = Left(sTemp, Len(sTemp) - Len(sDelimiter))
    End If
    
    StringMatch = sTemp
    
    End Function
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    This only returns one cell at a time. Please help to make it or help me with a new code to compare array and return the second array.

    Please Help!!


    Arun Menon
    Last edited by 6StringJazzer; 05-05-2018 at 08:31 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how return an array of user defined datatype
    By whburling in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-26-2017, 03:04 PM
  2. Replies: 4
    Last Post: 03-31-2017, 05:49 AM
  3. Passing an array in a user defined function
    By Peter M in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2013, 01:15 AM
  4. User-Defined Function & Array Formulas
    By faithcmbs9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 05:46 PM
  5. Creating An Array to Be Used In a User Defined Function
    By ashleys.nl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2012, 08:17 PM
  6. user defined function using Array
    By Dennisli2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2007, 02:00 PM
  7. How to get a return value from a user defined function
    By Glen Mettler in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2005, 12:05 PM

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