+ Reply to Thread
Results 1 to 10 of 10

Formula to Count Up to a Specific Value as Repeating Number

  1. #1
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Formula to Count Up to a Specific Value as Repeating Number

    I'm trying to send out lists to workers that gives them approximately 20 people each. I've already got the data, but ultimately I'd like to turn this into a PDF for each worker (which I would normally use subtotals/page breaks for) -- but I can't because there's no recurring information that would allow subtotals to work properly.

    So, basically, if I wanted Excel to count up to 20 but using '1's every time, then when it hits 20, switch to '2's, etc. -- is that possible? This would allow me to use the subtotals function to break the pages properly.

    Thank you!

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Assuming you want this value in column A

    Please Login or Register  to view this content.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Formula to Count Up to a Specific Value as Repeating Number

    No need for VBA for this. Put this in the cell where you want the numbering to start, and copy down...
    =INT(ROW(A1)/20)+1

    (not sure how this will be affected by subtotals, though)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Quote Originally Posted by FDibbins View Post
    No need for VBA for this. Put this in the cell where you want the numbering to start, and copy down...
    =INT(ROW(A1)/20)+1

    (not sure how this will be affected by subtotals, though)
    Thanks! Works great. If subtotals affect it, I'll just copy and paste with values.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Glad it worked fror you and thanks for the feedback

  6. #6
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Actually -- it's so close to perfect I almost missed a quick flaw. When I do this, the first grouping of '1's only count up to 19 for some reason -- which throws off the rest (that correctly count to 20).

    Any idea why? I'm using the formula in Cell M2 and the formula exactly how you wrote it above. If I change ROW(A1) to ROW(A2) for example, I've noticed that the first grouping of '1's go down to a count of 18 -- if you change it to ROW(A3), it goes down to a count of 17, etc. But the remainder of the list stays correct (all other numbers are groupings of 20).

    Know what I can do about this? It's throwing everything off by one.

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Hi All,

    a small adjustment could be

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


    Cheers
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  8. #8
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Formula to Count Up to a Specific Value as Repeating Number

    Quote Originally Posted by FDibbins View Post
    No need for VBA for this. Put this in the cell where you want the numbering to start, and copy down...
    =INT(ROW(A1)/20)+1

    (not sure how this will be affected by subtotals, though)
    sometimes I think I use a sledgehammer to crack a nut! Just shows theres usually an easy answer

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Formula to Count Up to a Specific Value as Repeating Number

    canapone, thanks for the assist, nicely done

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formula to Count Up to a Specific Value as Repeating Number

    never know why int() is used there is a very useful function called ceiling()
    =CEILING(ROW(A1)/20,1)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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] Count number of days from column of repeating dates
    By Edwardbigfoot in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-28-2013, 04:22 PM
  2. Need formula to count specific number of cells
    By FairfaxHS in forum Excel General
    Replies: 2
    Last Post: 05-18-2012, 04:10 PM
  3. Replies: 1
    Last Post: 03-05-2011, 04:18 PM
  4. Repeating A values a specific number of times
    By Dav in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2008, 02:10 AM
  5. Repeating items a specific number of times
    By ninja0059 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2008, 01:19 PM

Tags for this Thread

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