Ozgrid Excel Help & Best Practices Forums


XL Templates | XL Add-ins | XL Training | XL Estimating | XL Scheduling | XL Recovery | XL Trading | XL Financial | XL Conversion | XL Charting


+ Reply to Thread
Results 1 to 4 of 4

Thread: Find Words From One Range In Another

  1. #1
    Join Date
    8th December 2006
    Posts
    2

    Find Words From One Range In Another


    Download Active Data For Excel > > DETAILS > >
    I need a way to do the following in Excel:

    column A has text
    column B needs a Formula that returns specific value(s)
    ie. want to find any of 17 specific strings within a row in column A and return that (those) string value(s) in column B

    for example row1 column A contains the following:
    Troubleshooter Notes: Sound KVSND Tree was not used as doc exists that covered the specific issue

    The formula in column B needs to be able to find any of the following values (note: these values could be placed in a lookup table):
    "KVBAT" "KVBLTH" "KVDNW" "KVDOC" "KVDWB" "KVFLSH" "KVKBD" "KVLAN" "KVODD" "KVOTH" "KVPFS" "KVRCVY" "KVSB2" "KVSFT" "KVSND" "KVVID" "KVWFI"

    and place the found value(s) in row 1 column B

    in the above example column B would return the value:
    KVSND

    the formula needs to be diverse enough to return multiple values if more than 1 value is found

    for example row1 column A:
    Troubleshooter Notes: Sound KVSND Tree was not used as doc exists that covered the specific issue, Performance Security Troubleshooter KVPFS The system has worked previously performance expectation is being set by previous performance or a message

    row 1 column B should return the following values (preferably with a space between each value):
    KVSND KVPFS

    Thank you for your help,
    syl

  2. #2
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    51,286

    Re: Search A Cell If Contains A String That Matches A Range Of Strings

    Create 2 Dynamic Named Range. Name the one with "KVBAT" "KVBLTH" "KVDNW" etc as LookRange and the other FindRange. Now run the code below. It will place the matching into the Column (same row as match) to the immediate right of FindRange.
    Code:
    Sub FindText()
    Dim rCell As Range, rFindIn As Range
    Dim strWord As String, lLoop As Long
    Dim rFound As Range
    
        Set rFindIn = Range("FindRange")
        
        For Each rCell In Range("LookRange")
        
            strWord = rCell
            Set rFound = rFindIn.Cells(1, 1)
            
            For lLoop = 1 To WorksheetFunction.CountIf(rFindIn, "*" & strWord & "*")
            
               Set rFound = rFindIn.Find(What:=strWord, After:=rFound, LookIn:=xlValues, LookAt _
                    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False)
                    
                    rFound(1, 2) = strWord
                    
            Next lLoop
        Next rCell
    
    End Sub
    Last edited by Dave Hawley; December 8th, 2006 at 14:25.

  3. #3
    Join Date
    8th December 2006
    Posts
    2

    Re: Find Words From One Range In Another

    Thank you Dave Hawley for your quick response. You ROCK!
    I will definately try this tomorrow when I get back to work. This will save me a lot of time (as I spent all day trying to figure this out with basic excel formulas and got nowhere).
    I am wondering if it would be a big or small modification to have the returned value in a non-adjacent cell for example instead of returning the value in row 1 column B, having the value returned in row 1 column Z? If its a big deal to make that modification then I'll just stick with the great help you have given me.

  4. #4
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    51,286

    Re: Find Words From One Range In Another


    Create Excel dashboards quickly with Plug-N-Play reports.
    The line of code rFound(1, 2) = strWord adds the word next to the row it was found in. The 1 means same row, and the 2 means one column to the right. In other words, to have it placed in the same row 5 columns to the right, it would be rFound(1, 6) = strWord. To have it offset one row down 5 columns to the right it would be rFound(2, 6) = strWord.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Possible Answers

  1. Find Matching Words In Two Columns
    By cheshirehouse in forum EXCEL HELP
    Replies: 4
    Last Post: June 17th, 2008, 00:22
  2. Find & Highlight Words In Cell
    By want2learn in forum EXCEL HELP
    Replies: 9
    Last Post: March 25th, 2007, 08:14
  3. Count Words In Range Mixed in With Other Words
    By aschroth in forum EXCEL HELP
    Replies: 7
    Last Post: November 10th, 2006, 11:19
  4. Replies: 3
    Last Post: June 23rd, 2006, 00:29
  5. find multiple words in once cell
    By mine in forum EXCEL HELP
    Replies: 12
    Last Post: August 31st, 2005, 23:02

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