+ Reply to Thread
Results 1 to 2 of 2

Check cell for word, If word exists in cell, assign that cell to corresponding category.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Check cell for word, If word exists in cell, assign that cell to corresponding category.

    Hi.
    I've tried a bunch of ways to do this and nothings been working. The Lookup and Match functions are not doing what I want. Is there a way for VBA to handle this problem?

    Problem.
    Sheet1(
    Column A contains names. These names are strings which contain Key words.
    Column F is blank. I want column F to be filled in with categories that those keywords belong to.
    )
    Sheet2(
    This contains a table. The Horizontal Axis is a list of Categories. The Vertical access is just a list of words
    associated with each category.

    I've attached a simplified example.

    If anyone can help with this It would be greatly appreciated.
    Attached Files Attached Files

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

    Re: Check cell for word, If word exists in cell, assign that cell to corresponding categor

    UDF

    =Getregion(A2,Sheet2!$A$1:$E$6)

    Option Explicit
    Option Compare Text
    
    Function GetRegion(txt As String, rng As Range) As String
        Dim a, i As Long, ii As Long
        a = rng.Value
        For ii = 1 To UBound(a, 2)
            For i = 2 To UBound(a, 1)
                If txt Like "*" & a(i, ii) & "*" Then
                    GetRegion = a(1, ii)
                    Exit For
                End If
            Next
            If Len(GetRegion) Then Exit For
        Next
    End Function
    Attached Files Attached Files
    Last edited by jindon; 12-12-2012 at 12:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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