+ Reply to Thread
Results 1 to 3 of 3

If a cell contains a string out of a list of strings.

  1. #1
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    If a cell contains a string out of a list of strings.

    Hello.
    I need a code to go trough a list and check each cell if they contain a string out of a list of possible strings (around 30 dif strings). If the cel do not contain any of those strings than paint the cell. I tryed something here, but its not working.

    Code:
    Sub Verificação_Comentário()
    Dim rw As Long, LR As Long


    LR = Range("A" & Rows.Count).End(xlUp).Row

    For rw = 3 To LR

    If InStr(1, Range("J3" & rw).Value, "AGUARDANDO REVISÃO", vbBinaryCompare) Then


    ElseIf InStr(1, Range("J3" & rw).Value, "ATENDIDO", vbBinaryCompare) Then

    ElseIf InStr(1, Range("J3" & rw).Value, "ATENDIDO ECODE", vbBinaryCompare) Then


    ElseIf InStr(1, Range("J3" & rw).Value, "ATENDIDO PVE", vbBinaryCompare) Then


    Else
    Range("J3" & rw).Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With


    End If


    Next rw
    End Sub

    End code.


    I cut some strings out to shorten the post.

  2. #2
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Re: If a cell contains a string out of a list of strings.

    I want it to start on row 3, but i dont know why it keeps on starting to check from row 33.

  3. #3
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: If a cell contains a string out of a list of strings.

    Hello
    Perhaps you could adapt a loop, for example:

    Please Login or Register  to view this content.
    This would loop through A2:A10 and check against (with another loop) the strings in G2:G6, all on Sheet1. This then fills the cells yellow if a match is found.

    DBY
    Last edited by DBY; 06-23-2016 at 09:18 AM. Reason: Amended code . Removed >0. Redundant.

+ 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: 9
    Last Post: 03-09-2015, 10:15 PM
  2. Matching a string against a list of strings
    By pranesh24 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-14-2013, 10:16 AM
  3. Replies: 3
    Last Post: 07-03-2013, 07:47 PM
  4. HELP - Evaluate large string in a cell against smaller strings in a List
    By caddidle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-06-2013, 01:31 PM
  5. How to find a string within another list of strings?
    By lmattenl in forum Excel General
    Replies: 7
    Last Post: 11-18-2012, 07:03 PM
  6. search for a part of string within an array of strings from another array list
    By jdonohue in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2011, 01:32 PM
  7. Finding Start Position of string in list of strings
    By longfisher in forum Excel General
    Replies: 5
    Last Post: 05-25-2007, 10:34 PM

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