+ Reply to Thread
Results 1 to 15 of 15

Finding frequency and repetition of values in cells in a row

  1. #1
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Finding frequency and repetition of values in cells in a row

    Hi, everyone. I'm hoping someone here can give me a hand. I've been at this for over a week and I've tried everything I could think of. I'm not great with Excel, so I'm hoping there is a way to do what I want.

    I have 10 cells in a row - A1-A10 for instance. Each cell will have a letter in it - the letters are determined from a list of about 8 possibilities. The letters I am concerned with are "R" and "D". What I need to be able to figure out is, from left to right (A1-A10) if a cell has an "R" in it, then a cell to it's right (anywhere in the row) has a "D". But I need to know if this happens twice. For instance, if the letters went like this:

    R T T H R D F R T D - this works, because there is a string of "R D R D" in it.

    R R R D T T H D R R - this doesn't work because there isn't an "R D R D" there.

    I hope that makes sense. I've attached a simple file with letters in cells - and also another file with my many different attempts in it. If anyone has an idea, I'd love to hear it. Thanks in advance for any help.

    Adam
    Attached Files Attached Files
    Last edited by NBVC; 01-25-2011 at 03:48 PM. Reason: poor title

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Try this UDF solution:

    Add the code to your VB editor (ALT+F11, Insert|Module)

    Please Login or Register  to view this content.
    Then apply formula in L4:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER not just ENTER

    copied down... assuming you don't have blank rows between...

    TRUE means the RDRD combination exists
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    Thank you so much for taking the time to help out. It doesn't seem to want to work for me. I get FALSE even if the RDRD combination is there. I inserted a new module, and also made sure I hit ctrl+shift+enter when I put the code in L4. I will also have blank rows in between the rows of data, so I'm not sure if this will work, per your second to last sentence above. Once again, thanks for taking a shot at this.

    Adam

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Make sure that after you enter the first formula that the cell is still active (i.e. the cursor is still there... or just hit F2 to make sure) then hold the CTRL and SHIFT keys down and hit ENTER.. you should see { } brackets appear around the formula, then copy it down.

    if the whole range in the alternate rows is blank, then use this formula in L4:

    =IF(COUNTBLANK(B4:K4),"",ISNUMBER(SEARCH("RDRD",(aconcat(IF(ISNUMBER(MATCH(B4:K4,{"D","R"},0)),B4:K4,""),"")))))

    confirmed again with CSE keys and copied down.
    Last edited by NBVC; 01-25-2011 at 03:33 PM.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Here is your attachment with UDF and formula
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    Didn't see your last post. Thank you SOOO much!! I'm still not sure what I was doing wrong. Thanks a million!!

    Adam

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Here it is again.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    Thanks - I think I figured out what I did wrong...I was pasting the code into the cell and the ctrl+shift+enter....wasn't working. I pasted the code into the formula bar at the top instead...probably a rookie mistake haha. Thanks again!

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    If you paste it into the cell, just hit F2 and then do the CSE entry.

  10. #10
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    The only problem I keep getting is if I have more than one D in between the R's, or more than one R between the D's:

    RRRDRD - works
    RRRDHTRD - works
    RDDRD - doesn't work
    RDRRD - doesn't work.

    Sorry if this one is becoming a pain for you. I truly appreciate the help. Thanks.

    Adam

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Sorry, not sure what the problem is. Can you elaborate?

  12. #12
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    I'm trying to find an R and then a D and then an R and then a D.

    this works:
    RDRD
    if I have other letters in between it works:
    RDFGRD
    but if I have more than one D in between the R's it doesn't:
    RDDRD doesn't work
    same if I have more than one R in between the D's it doesn't
    RDRRD doesn't work

    If you can have a look at B25:K25 in the attached, it might explain it better. Just in case what I've written still doesn't make sense. Thanks again!

    Adam
    Attached Files Attached Files

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    Try this in L4:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER and copied down.

    Note: I added more functionality to only skip rows that have all cells blank and to include rows that have a few cells within blank....not sure if you wanted that or not, though...

  14. #14
    Registered User
    Join Date
    01-25-2011
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Finding frequency and repetition of values in cells in a row

    Looks perfect!!! Thanks so much again! I really appreciate you taking the time to help me out with this. It's been over a week, couple hours a day, trying to figure this out! Thanks!

    Adam

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding frequency and repetition of values in cells in a row

    You are welcome

+ 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