+ Reply to Thread
Results 1 to 11 of 11

check group status

  1. #1
    Registered User
    Join Date
    04-01-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    42

    check group status

    hello!

    I have a text file (or EXCEL file) of the below format:

    1223{TAB}GSDF{TAB}OK
    1223{TAB}GSDG{TAB}OK
    1436{TAB}DFBB{TAB}OK
    1436{TAB}CBDF{TAB}NOT OK
    1436{TAB}TREG{TAB}OK
    etc

    I want to check which group (eg 1223, 1436) is OK or NOT OK
    If in a group, there is a single NOT OK, then the whole group is NOT OK. Else, it's OK (ie if all group lines are OK).

    please note that in the source text, the group entries will always be together (ie there will not be a 1436 line between two 1223 lines, etc), but I may add more columns (however the group column will always be the first and the status (OK or NOT OK) the last)

    thanks!
    Last edited by loade; 05-01-2012 at 10:02 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check group status

    1) In the Excel file, we assumed the codes are in column A, the "OK/NOT OK" flags in column C

    2) Highlight the first column of group codes and use the Data > Filter > Advanced Filter to make a copy of all the unique codes into another column, let's say column G

    3) If the first unique code in in G2, put this formula in H2 to get your answer:

    =IF(ISNUMBER(MATCH(G2&"NOT OK", INDEX($A$1:$A$100&$C$1:$C$100, 0), 0)), "NOT OK", "OK")

    ...copy that down.

    The formula uses the first 100 rows, expand it as needed to use a larger range. Don't try to use a whole column.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: check group status

    Where your original data is in A1:C5 and your unique groups are in Column G starting in G1

    =IF(SUMPRODUCT(--($A$1:$A$5=G1),--($C$1:$C$5="Not OK"))>0,"Not Okay", "Okay")
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    04-01-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: check group status

    okay, but I need it to work in any number of rows, not only in 5 rows
    any hint?

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: check group status

    Jerry's is set up for 100 rows. Just change the 5's in mine to any number and it'll work.

  6. #6
    Registered User
    Join Date
    04-01-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: check group status

    Quote Originally Posted by ChemistB View Post
    Jerry's is set up for 100 rows. Just change the 5's in mine to any number and it'll work.
    isn't there a way that it will detect all the rows available and do it? it needs a macro?

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check group status

    You would normally post macro questions in the Programming Forum, which is why we're struggling to give the simplest formula we can.

    Here's a dynamic version of my original formula that will work for any amount of data in A:C, matching a code in G2:

    =IF(ISNUMBER(MATCH(G2&"NOT OK", INDEX(OFFSET($A$1,,,COUNTA($A:$A),)&OFFSET($A$1,,2,COUNTA($A:$A),), 0), 0)), "NOT OK", "OK")

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check group status

    All good?

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

  9. #9
    Registered User
    Join Date
    04-01-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: check group status

    yes thanks!!

  10. #10
    Registered User
    Join Date
    04-01-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: check group status

    unfortunately it is not handy :/

    I need it to automatically select all the non-empty cells (apart from first row, which is header row) and then to calculate the OK, NOT OK status of each group (rows of the same group are those that have the same number at column A), as stated above (ie. if a group has a single NOT OK, then it's NOT OK, otherwise, it's OK)

    then, display in columns I, J the group number and the status at right

    I tried with macro, but dont know what to search for, does it need RegEx?
    any hint??

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check group status

    I understand "It's not handy". It works for me, takes about 10 seconds to do the Advanced Filter, and another 10 to copy the formula in and down the data set.

    Now that you have the working formulas, you could record yourself applying the Adv Filter and entering the formulas to get the base code. A few tweaks on that would give you a reusable macro that does the same thing.

+ 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