+ Reply to Thread
Results 1 to 14 of 14

Count rows and display the results

  1. #1
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Count rows and display the results

    Please see the attached picture for details of what I'm trying to accomplish.

    I have a string of numbers in A. Each number is separated by commas. Going down the column I would like to check the skipped rows of each number until it shows up again in the column.

    For example Column B on row 6 shows 1 - 2 - x - 4 - x

    # 02 skipped one row from row 4 to row 6 so the result on B should be (1)
    # 05 appeared on row 3 then skipped 2 rows and it is again in row 6, so skipped (2)
    # 22 and 33 are not on previous rows so it is first time numbers (x)
    # 25 was on row 1 and skipped 4 rows before showing up on row 6 so skipped (4).

    I can separate the string into columns of that option will be easier.

    Any help is appreciated.

    excel_skip.jpg

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    WT please upload a sample Excel workbook (not pics or screenshots ... it saves us having to retype data you already have.)

    If you are not familiar with how to do this:

    To attach a file to your post,
    • be sure to desensitize the data
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”

    The file name will appear at the bottom of your reply.
    Dave

  3. #3
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Count rows and display the results

    Thank you FlameRetired for your message. Here is the excel workbook.
    Regards
    Attached Files Attached Files

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    WT there are versions of Excel with features worth exploring, but not if they do not apply. For ex. Flash Fill.

    That said please update your profile to let us know what version(s) of Excel you have.

  5. #5
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Count rows and display the results

    Office 2010. Thank you.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    Thank you WT.

    I couldn't come up with any formula approach that didn't require helper columns.

    This formula in B2 filled down and across does that. It parses the original strings.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In the calculated section "x - " is the default for H2:L2. Starting in H3 filled down and across.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then the final concatenated output in column N
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    I noticed a possible error in my previous formula in H3:L17. It calculates the difference between the current number row and the first occurrence of that number. This formula calculates the difference between the current row and the most recent previous (last) occurrence. I suspect this is what you want?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Count rows and display the results

    Yes the second file it much better.
    I still found some miscalculations in some columns but like I said, much better.
    Here is the file with the errors.
    Thank you.
    Attached Files Attached Files

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    Array enter this formula in H3 fill down and across. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    There were some repeating spaces in column P. Once cleaned up the only FALSE is in row 11. I believe my formula is correct. Can you double check L11?
    Attached Files Attached Files

  10. #10
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,911

    Re: Count rows and display the results

    Or try in H2:

    =IFERROR(ROW()-LARGE(IF($B$1:$F1=B2,ROW($B$1:$F1)),1)-1,"x")&IF(COLUMNS($H1:H1)<5," - ","")

    Enter with Ctrl+Shift+Enter.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    @Phuocam
    Nice one. Very compact.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    Phuocam you are an inspiration.

    Try this non array in H2.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Count rows and display the results

    @FlameRetired your last two codes worked like a charm. Thank you!

    I noticed the extra space on P12 so once I fixed that it changed to TRUE. Also I made a mistake on P11, it should be 7 - 1 - 5 - 5 - 2 and it is also TRUE.

    @Phuocam Thank you, it also worked like a charm.

    Very happy receiving great help here from nice guys.

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Count rows and display the results

    You are welcome. Thank you for the kind words and follow-up re: typos.

+ 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. Search against a range of criteria and display whole rows as results
    By ahber in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-19-2013, 08:55 AM
  2. [SOLVED] Count if, display results in msgbox
    By j9070749 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-24-2012, 12:22 AM
  3. Count in filtered list and display results in table on right of data
    By raydaw in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-27-2009, 05:14 AM
  4. with Autofilter on, display count results in lower left corner wit
    By jsky in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-03-2005, 06:05 PM
  5. Display count of rows
    By Biff in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 12:05 PM
  6. Display count of rows
    By Judy Ward in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. Replies: 2
    Last Post: 07-21-2005, 07:05 PM
  8. Display count of rows
    By Judy Ward in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2005, 03:05 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