Results 1 to 5 of 5

Thread: If formula to look for Letter Patterns or Behaviors

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0

    If formula to look for Letter Patterns or Behaviors

    I am trying to find a behavioral pattern. Therefore, I am hoping some IF formulas will work. Each formula would be a "scenario" and be in its own column. Thank you in advance for any advice you can give.

    1) Where "J" is before "K" then put a "1". If "K" precedes "J", then it's value is "2". Everythng else should be blank

    2) Where "J" is before "L" but does not include "K". If True, put a "1". If false, leave blank

    3) Where "J" is before "K" and both are before "L". Must contain all three letters to be true. If true, then put a "1". Leave Blank if false

    4) Where "J" but no "K" or no "L" then "1" if True.

    D
    DH
    DHJ
    DHJCK
    DKJ
    DJL
    DJKL
    DHGKL
    K
    L
    KL

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    14
    These formulas should do what you want...

    1) =IF(COUNTIF(A2,"*J*K*"),1,IF(COUNTIF(A2,"*K*J*"),2 ,""))

    2) =IF(COUNTIF(A2,"*J*L*"),IF(COUNTIF(A2,"*K*"),"",1) ,"")

    3) =IF(COUNTIF(A2,"*J*K*L*"),1,"")

    4) =IF(COUNTIF(A2,"*J*"),IF(OR(COUNTIF(A2,"*K*"),COUN TIF(A2,"*L*")),"",1),"")

  3. #3
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    There may be better ways..

    =IFERROR(LOOKUP(3,CHOOSE({1,2,3,4},IF(AND(ISNUMBER (SEARCH("j",A2)),OR(NOT(ISNUMBER(SEARCH("k",A2))), NOT(ISNUMBER(SEARCH("l",A2))))),1,""),IFERROR(IF(A ND(SUM(SEARCH({"j","k"},A2)*{1,-1})<0,ISNUMBER(SEARCH("l",MID(A2,SEARCH("k",A2),25 5)))),1,""),""),IFERROR(IF(AND(SUM(SEARCH({"j","l" },A2)*{1,-1})<0,NOT(ISNUMBER(SEARCH("k",A2)))),1,""),""),IFE RROR(IF(SUM(SEARCH({"j","k"},A2)*{1,-1})<0,1,2),""))),"")
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0
    Rick,
    THANK YOU THANK YOU THANK YOU.....YOU are a EXCEL GENIUS. Saved me countless headaches! thanks again.

  5. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0
    Admin,
    Wow, your formula is COMPLEX. It looks like it could do all in one formula vs the way I had asked originally, which was to put each formula in its own column. I will attempt to understand your formula as it truly is mind blowing. you guys are super excel geniuses!!!!

    thanks

Similar Threads

  1. Converting a Column Number to a Column Letter
    By Rasm in forum Excel and VBA Tips and Tricks
    Replies: 6
    Last Post: 12-17-2012, 02:29 AM
  2. Replies: 11
    Last Post: 10-07-2012, 12:05 AM
  3. First Letter From Words VBA - Acronymize
    By 1.12 in forum Excel Help
    Replies: 2
    Last Post: 04-02-2012, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •