+ Reply to Thread
Results 1 to 8 of 8

Logic for closest to a variable number without exceeding it based off a helper column

  1. #1
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Logic for closest to a variable number without exceeding it based off a helper column

    So, I am having quite the difficult time coming up with the logic for this one...

    To explain it as simply as possible, I have a helper column (used for other things, but should prove useful in this case) with numbers ascending until the value changes in a different column, then they reset to 1. What I want to do is insert a page break so there is never the same values on different pages. So if by default, every 46 lines after a page break, another is automatically inserted, that would be our maximum value. so it would be the closest to 46 lines without exceeding 46 lines, with a 1 in the column next to it. I provided example "line counts" in the first column, those don't need to be there, it is more or less to help illustrate what I tried to explain. I can see counting backwards from 46 also being useful, so don't let my "help" hinder you when coming up with possibilities for logic. Adding in more helper columns is also an option, feel free to brute force this however you deem necessary.

    Once this is solved, I can nest this formula with my other formula that decides page breaks based on a different criteria, to automatically decide where they should be, then a macro can do the rest. The problem I am having with this is the extremely fuzzy logic of some number less than or equal to 46 with a strange variable criteria like that. Any and all help will be greatly appreciated, I'll keep trying to come up with my own solution in the meantime of course.

    Example data below, notice how it adjusts so all the nnn's remain on the same page:

    formula helper values
    count starts here 1 aaa
    2 2 aaa
    3 3 aaa
    4 4 aaa
    5 1 bbb
    6 2 bbb
    7 3 bbb
    8 1 ccc
    9 1 ddd
    10 2 ddd
    11 3 ddd
    12 4 ddd
    13 5 ddd
    14 1 eee
    15 2 eee
    16 3 eee
    17 1 fff
    18 1 ggg
    19 1 hhh
    20 1 iii
    21 2 iii
    22 3 iii
    23 4 iii
    24 1 jjj
    25 2 jjj
    26 3 jjj
    27 4 jjj
    28 5 jjj
    29 1 kkk
    30 2 kkk
    31 3 kkk
    32 4 kkk
    33 1 lll
    34 2 lll
    35 3 lll
    36 4 lll
    37 5 lll
    38 1 mmm
    39 2 mmm
    40 3 mmm
    41 4 mmm
    42 5 mmm
    43 6 mmm
    page break (44) 1 nnn
    2 (45) 2 nnn
    3 (46) 3 nnn
    4 4 nnn
    5 5 nnn
    6 6 nnn
    7 1 ooo
    8 2 ooo
    9 3 ooo
    10 4 ooo
    11 5 ooo
    12 1 ppp
    13 2 ppp
    14 3 ppp
    15 4 ppp
    16 5 ppp
    17 1 qqq
    18 2 qqq
    19 3 qqq
    20 4 qqq
    21 1 rrr
    22 2 rrr
    23 3 rrr
    24 4 rrr
    25 1 sss
    26 2 sss
    27 3 sss
    28 4 sss
    29 5 sss
    30 6 sss
    31 1 ttt
    32 2 ttt
    33 3 ttt
    34 4 ttt
    35 1 uuu
    36 2 uuu
    37 3 uuu
    38 1 vvv
    39 2 vvv
    40 3 vvv
    41 1 www
    42 2 www
    43 3 www
    44 1 xxx
    45 2 xxx
    46 3 xxx
    page break 1 yyy
    2 1 zzz
    3 2 zzz
    4 3 zzz
    5 4 zzz
    6 1 AAAA
    7 2 AAAA
    8 3 AAAA
    9 4 AAAA
    etc. etc. etc.
    Last edited by TheN; 03-10-2017 at 02:20 AM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Tricky Logic with helper columns

    Administrative Note:
    • We would love to continue to help you with your query, but first, before we can proceed…
    • Please see Forum Rule #1 about proper thread titles and adjust accordingly...
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Tricky Logic with helper columns

    i'm not sure how to title this accordingly? suggestions are welcome.

    Maybe this will be better?

  4. #4
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Logic for closest to a variable number without exceeding it based off a helper column

    Updated with a much more thorough description, hopefully this is helpful. Unsure if people aren't responding because they are as baffled as me, or the problem isn't illustrated well enough.

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,459

    Re: Logic for closest to a variable number without exceeding it based off a helper column

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Quang PT

  6. #6
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Logic for closest to a variable number without exceeding it based off a helper column

    you can quite literally copy paste the table into an excel file and it keeps the data separate as is. The benefit of the table is you do not need to have access to excel to help someone, or view the sample data. For example, if you were to view this on a phone.

    I'll put a file here I guess.
    Attached Files Attached Files

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,459

    Re: Logic for closest to a variable number without exceeding it based off a helper column

    Not sure I have interpreted exactly, but try :
    B2:
    =COUNTIF($C$1:C2,C2)
    A2:
    Please Login or Register  to view this content.
    Copy A2:B2 down

  8. #8
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Logic for closest to a variable number without exceeding it based off a helper column

    yes, that will work well enough, thank you very much.

    That is a nice use of nesting there, very cool formula.

+ 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] Combine 2 Columns from 2 different sheets with helper
    By Sekars in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-21-2017, 09:33 AM
  2. Sort by helper column even if values in helper are alike
    By NoSleepForMe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-10-2016, 04:14 AM
  3. Tricky Question based on logic
    By raman1667 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2015, 03:45 AM
  4. multiple helper columns
    By ammartino44 in forum Excel General
    Replies: 6
    Last Post: 03-25-2015, 02:52 PM
  5. [SOLVED] Get rid of helper columns
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-24-2014, 05:26 PM
  6. Why do most refuse to use helper columns?
    By Fotis1991 in forum The Water Cooler
    Replies: 23
    Last Post: 12-02-2012, 10:11 AM
  7. Helper columns
    By Blake 7 in forum Excel General
    Replies: 3
    Last Post: 02-23-2011, 06:42 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