+ Reply to Thread
Results 1 to 4 of 4

Check If a Cells Contains Groups of Text

  1. #1
    Registered User
    Join Date
    12-04-2007
    Posts
    30

    Check If a Cells Contains Groups of Text

    Hello Community

    I have been pulling my hair out with an Excel VBA problem which I was hoping someone could help me with.

    I have the following data:-

    excelllll.JPG

    Hoping you can see the data. If you cannot I have in
    Row 2, Column A = [1100 2100 3601] Text3020 Work
    Row 2, Column B = YES or NO
    Row 2, Column C = DOWN SLOW 2100 UP SLOW 3601 UP MAIN 1100

    What I am trying to do is take the text in the square brackets in row 2 column A [1100 2100 3601]
    And then check if ALL of these values are contained in Row 2 Column C
    If Row 2 Column C does contain all of the values in the square brackets from row 2 column A then Row 2 Column B is YES, otherwise it is no.
    I want I repeat this until I have checked all rows in column A

    The bits of code I have found so far include:-

    Dim sCellVal As String
    sCellVal = Range("B2").Value
    If sCellVal Like "1100 2100 3601" Then
    Cells(1, 1) = "YES"
    Else
    Cells(1, 1) = "NO"
    End If
    End Sub

    Sub sadfsa()
    A = 1100
    B = 2100
    C = 3601
    Dim celltxt As String
    celltxt = ActiveSheet.Range("B2").Text
    If InStr(celltxt, A) And InStr(celltxt, B) And InStr(celltxt, C) Then
    MsgBox ("found it")
    Else
    MsgBox ("no")
    End If
    End Sub

    But none of the above works.

    Can anyone help please?

    I am using Excel 2003











    I am using excel 2003

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Check If a Cells Contains Groups of Text

    Hi Mark,

    First could you edit your post above and select the "Code" and then click on the "#" icon above to put code tags around your code.

    I'd do your problem by.. using Split and then go through all/any bracket numbers.
    Please Login or Register  to view this content.
    Note - code untested as I got a doorbell ring.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

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

    Cool Hi ! Try this ‼


    As an Excel basics starter :

    PHP Code: 
    Sub Demo1()
            
    Dim VR&, S$()
                
    = [{"YES","NO"}]
        
    With Application
               
    .ScreenUpdating False
            
    For 2 To Cells(Rows.Count1).End(xlUp).Row
                S 
    Split(Split(Split(Cells(R1).Value"]")(0), "[")(1))
                
    Cells(R2).Value V(+ (.Count(.Match(SSplit(Cells(R3).Value), 0)) = .CountA(S)))
            
    Next
               
    .ScreenUpdating True
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 07-06-2018 at 05:52 AM. Reason: optimization …

  4. #4
    Registered User
    Join Date
    12-04-2007
    Posts
    30

    Re: Hi ! Try this ‼

    Thanks Marc L

    Really appreciate this and yes it did work.

    Great Stuff.

+ 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] Formula to check that the weightings for various KPI groups all add to 100%
    By The_Snook in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-16-2017, 11:50 AM
  2. [SOLVED] Formula to check Groups of same value and return a value based on another Col
    By hammer2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-29-2017, 01:02 AM
  3. Replies: 2
    Last Post: 05-31-2013, 12:01 AM
  4. Need a Formula to Check an Audit Log Against a List of Groups of People
    By badmoon75 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-22-2012, 11:44 AM
  5. Analysing groups of cells to form new groups
    By lurker17260 in forum Excel General
    Replies: 3
    Last Post: 02-08-2012, 04:45 PM
  6. ActiveX Check Box - Groups w Only one Value Allowed
    By BrianFawcett in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 06-14-2011, 10:59 AM
  7. Check if all option button groups have a value
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2011, 11:02 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