+ Reply to Thread
Results 1 to 6 of 6

match words and extract out

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-02-2012
    Location
    malaysia
    MS-Off Ver
    Excel 2016
    Posts
    140

    match words and extract out

    Hi..
    I need help

    I have data in sheet1 and sheet2

    What i want , whatever words which start at first match with sheet2 extract out into output sheet

    For an example

    if the Data in sheet1 column A is like "Tommy s/b","Tommy c/o","tommy,bhd"
    but in sheet2 data in column A2 is "Tommy sdn Bhd"

    Data in sheet2 Column A match with Data in sheet1 column A extract out all the data which start from words Tommy..
    and delete all blank columns after extract out the data


    I have attached sample in excel file

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: match words and extract out

    Hi, mathanraj76,

    you should attach a sample that reflects what you are asking for, not one where everything has been resolved. I think you have been told so on the last thread as well: show the situation as is and the expected result. No Tommy in Sheet1 or Sheet2, no possible matches from Sheet1 in Sheet2 left, no outcome.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    10-02-2012
    Location
    malaysia
    MS-Off Ver
    Excel 2016
    Posts
    140

    Re: match words and extract out

    what i meant is whatever words start from left in sheet1 column A2 must match with sheet2 column A2 and extract it out into sheet output..

    I have 30,000 data's in sheet1 ..but i can't do it i manual way..

    Thanks
    Rj

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: match words and extract out

    Hi, mathanraj76,

    you would need to supply a sample which holds the origiunal data for each and every record you have put into Outcome as a sample in Sheet1 - I doubt itīs good practise to feature LOT PT 8070, JALAN 82/26, MUKIM SETAPAK in Output with no match in Sheet2. And neither CHIN HO-(HO) KUALA LUMPUR (B)-LCSB nor DAIE ENG. SB from Sheet1 are listed on Sheet2.

    So what shall we code for if there is nothing to match? You would need to deliver samples for this question.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    10-02-2012
    Location
    malaysia
    MS-Off Ver
    Excel 2016
    Posts
    140

    Re: match words and extract out

    Thanks
    I make some mistake in there ..
    I'm sorry..

    I have attached another sample excel file..
    Those strings in sheet1 column A2 match with sheet2 column A2 string and extract out into sheet output..

    For an example if the string in sheet1 column A2 is "simon sb" , A3 " simon ltd", A4 " simon ltd incs" match with sheet 2 column A2 simon sb
    so..those words which start from "Simon" all extract out the whole data and put into sheet 3..
    Those which not same will remain i sheet 1..


    Thanks
    Rj
    Attached Files Attached Files

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: match words and extract out

    Hi, mathanraj76,

    I wouldnīt search for just a single character like 5 or B which could lead to some unwanted results. Thatīs where an unique identifier would come in very handy.

    Sub EF977853()
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    Dim lngCounter As Long
    Dim var As Variant
    Dim strSearch As String
    
    Set ws1 = Sheets("Sheet1")
    Set ws2 = Sheets("Sheet2")
    Set ws3 = Sheets("output")
    
    With ws1
      For lngCounter = 2 To .Range("A" & Rows.Count).End(xlUp).Row
        var = Split(.Cells(lngCounter, "A").Value, " ")
        If WorksheetFunction.CountIf(ws2.Range("A:A"), var(0) & "*") > 0 Then
          ws3.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Resize(1, 11).Value = _
              .Range("A" & lngCounter).Resize(1, 11).Value
          .Range("A" & lngCounter).Resize(1, 11).ClearContents
        End If
      Next lngCounter
    End With
    
    Set ws3 = Nothing
    Set ws2 = Nothing
    Set ws1 = Nothing
    
    End Sub
    Ciao,
    Holger

+ 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. [SOLVED] looking formula for Extract Specific WORDs in existing LONG Words
    By santosh226001 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-07-2013, 08:21 AM
  2. Help! Count how many words in a sentence match a dictionary of words
    By sonyaelis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2013, 05:31 AM
  3. Replies: 1
    Last Post: 04-04-2012, 07:15 PM
  4. Extract all but last two words
    By rwl518p in forum Excel General
    Replies: 2
    Last Post: 12-12-2011, 10:06 AM
  5. Match similar words to array and get row number of match
    By steefa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-22-2009, 10:41 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