+ Reply to Thread
Results 1 to 6 of 6

Check for strings in each cell and print strings in adjacent cell if they appear

  1. #1
    Registered User
    Join Date
    05-03-2019
    Location
    Chicago, IL
    MS-Off Ver
    365
    Posts
    10

    Check for strings in each cell and print strings in adjacent cell if they appear

    Hello,

    I'm trying to take each cell in column A and check to see if it contains any of the strings in tagList; then, if it does contain one, it should print a string in column B in the same row consisting of 'TAG1 & ", " & TAG2', etc, depending on which tags it contains.

    This is what I have so far; I haven't done VBA in a long time so I'm sort of frankensteining other code snippets to build this out, and cant figure out the action to take at each step in the For loop.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Pawtang; 08-21-2019 at 10:00 AM. Reason: adding file

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi !

    Attach a workbook with the source data and the expected result …

  3. #3
    Registered User
    Join Date
    05-03-2019
    Location
    Chicago, IL
    MS-Off Ver
    365
    Posts
    10

    Re: Check for strings in each cell and print strings in adjacent cell if they appear

    Added file

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

    Re: Check for strings in each cell and print strings in adjacent cell if they appear

    Try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-03-2019
    Location
    Chicago, IL
    MS-Off Ver
    365
    Posts
    10

    Re: Check for strings in each cell and print strings in adjacent cell if they appear

    I managed to get it working using the following, which works slowly but does the task.
    Is this a poor way to execute?


    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to your attachment as a beginner starter :

    PHP Code: 
    Sub Demo1()
            
    Dim GA$(), R&, S$(), VW
                G 
    = [G1].CurrentRegion.Rows("2:" & [G1].CurrentRegion.Rows.Count).Value2
        With 
    [A1].CurrentRegion.Rows
                ReDim A
    (2 To .Count0)
            For 
    2 To .Count
                    S 
    Split(Replace(.Cells(R2).Value2","""))
                For 
    Each V In G
                    W 
    Application.Match(VS0)
                    If 
    IsError(WThen W Application.Match("S"S0)
                    If 
    IsNumeric(WThen A(R0) = IIf(A(R0) > ""A(R0) & ", """) & V
                Next
            Next
                
    .Item("2:" & .Count).Columns(1).Value2 A
        End With
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 08-21-2019 at 10:57 AM.

+ 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. Macro to Delete only Alpha Strings but not Alphanumeric or Numeric Strings in a Cell
    By papageorgio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 06:55 AM
  2. Replies: 4
    Last Post: 05-30-2015, 11:45 AM
  3. [SOLVED] Format individual strings out of multiple strings within a cell with VBA
    By jrtraylor in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-18-2013, 07:33 PM
  4. Replies: 3
    Last Post: 05-28-2011, 01:43 PM
  5. Using small dictionary, find strings, fill adjacent cell
    By Rockofeller in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2011, 12:41 AM
  6. most efficient way to check cell data against 3 known strings
    By scudder12 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2010, 06:01 AM
  7. Replies: 2
    Last Post: 12-18-2009, 10:59 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