+ Reply to Thread
Results 1 to 12 of 12

Search and Extract text from a list of description

Hybrid View

  1. #1
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Search and Extract text from a list of description

    Hi everyone!

    I'm not at all good at creating macros, but I was wondering if anyone has something which might be able to help me with a project I'm working on. Basically, I'll be auditing several descriptions from a database. I'd like to search if a client from a list in the Client tab was mentioned in any of the description found in the Lite tab of the worksheet. Once found in the description, the matching client name should be written under the Client Name column in the Lite tab. I've attached the file for reference. Needing urgent help for this one if possible.

    Thanks and appreciate any insight!
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Search and Extract text from a list of description

    What would a sample answer look like?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    Hi!

    It should look something like the attached in the Sample tab. So if it does not find either an exact match or partial match to any of the client name, it should leave the Client Name column in the "Lite" tab blank and if it's able to find a match, it should populate the Client Name column with the matching word.

    Thanks so much!
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Search and Extract text from a list of description

    Why Federal Express; FedEx in row 3?
    Sub test()
        Dim a, i As Long, myPtn As String, m As Object, dic As Object
        Set dic = CreateObject("Scripting.Dictionary")
        dic.CompareMode = 1
        With Sheets("client")
            myPtn = Join(Application.Transpose(.Range("a2", .Range("a" & Rows.Count).End(xlUp)).Value), Chr(2))
        End With
        With Cells(1).CurrentRegion.Resize(, 2)
            .Columns(2).Offset(1).ClearContents
            a = .Value
            With CreateObject("VBScript.RegExp")
                .Global = True
                .Pattern = "([$()^\-|{}\[\]+*?.])"
                myPtn = Replace(.Replace(myPtn, "\$1"), Chr(2), "|")
                .Pattern = "\b(" & myPtn & ")\b"
                For i = 2 To UBound(a, 1)
                    For Each m In .Execute(a(i, 1))
                        dic(m.Value) = Empty
                    Next
                    If dic.Count Then a(i, 2) = Join(dic.keys, "; ")
                    dic.RemoveAll
                Next
            End With
            .Value = a
        End With
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    Hey, thanks for the macro. I'll try to run this...I'll be including FedEx as a variation to how Federeal Express Corporation is entered in the description. Some marketing description use abbreviations so I would also need to include that in the list. I appreciate your reply and will let you know how it works

  6. #6
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    Hi,

    I tried running the macro and it works like how i want it to but it's unable to pick up some of the client names like abbott, l'oreal, the body shop etc...

  7. #7
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    Is it because the actual file which I'm using the macro on has more than 9000 entries? so sorry...i was unable to attache the entire list because of the limitations in the allowable file size...

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Search and Extract text from a list of description

    If you are talking about the file other than the one you have uploaded, I have no idea.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Search and Extract text from a list of description

    Just upload the data and the list that hasn't been picked up.
    You don't need to upload entire file and I don't even see it at all...

  10. #10
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    The macro stops when there's a blank field cell in the marketing description column so I just populated it with a random word for now

  11. #11
    Registered User
    Join Date
    01-14-2016
    Location
    Philippines
    MS-Off Ver
    Windows 7 Enterprise
    Posts
    7

    Re: Search and Extract text from a list of description

    sorry...i think i know what the problem is now...thanks so much! i appreciate you taking the time to respond to my questions!!!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Search and Extract text from a list of description

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 02-20-2014, 12:24 PM
  2. VBA: Search text and extract hyperlink in same cell
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2013, 11:59 AM
  3. Search/extract text
    By Plasma in forum Excel General
    Replies: 3
    Last Post: 01-17-2012, 12:16 PM
  4. search and extract within text
    By sunnyday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2005, 10:05 PM
  5. Replies: 9
    Last Post: 08-31-2005, 12:05 AM

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