+ Reply to Thread
Results 1 to 16 of 16

Formula to add one to the previous column, with one exception

  1. #1
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Formula to add one to the previous column, with one exception

    DA6.jpg

    The pictures shows the general layout of what I want. I entered these numbers manually but I'm looking for a formula to do it.

    Each column simply adds one to the previous column, with one exception. There are different set of numbers for work days and non-work days. So if my number on Monday is 5, Tuesday will be 6, Wednesday will be 7...Friday would be 9. But when you get to the weekend (or Holiday) my "non-workday" number may be 5, which would make Sunday 6, but then Monday would be 10 because it's going off the 9 from Friday. The next non-workday would be 7 going off the 6 from last Sunday.

    I want one formula that I can drag across the row that will be able to add one to the previous day respectively (work day or non-work day).

    This is used to assign duty. The person with the highest number gets assigned the duty that day if there are any. On a day that duty is assigned, a "0" is entered, restarting that persons number. The next same type day would be a 1 then.

    Thanks.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: If? Hlookup? Vlookup? Idk

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: If? Hlookup? Vlookup? Idk

    I tried to upload the sheet the first time and it didn't work which is why I did the picture. See if this works.

    So there are about 50 rows of names and the columns can go forever. That being said we normally plan about 90 days out.
    Attached Files Attached Files
    Last edited by scheidc; 11-22-2018 at 01:04 PM.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula to add one to the previous column, with one exception

    Apols. I didn't notice your reply. Anyhow. I had to add two "pump priming" columns... to reflect the position IMMEDIATELY before the start date. I tidied up your CF a bit, so that zeros and weekends are CF'd the way you want them (copy/pasting across screwed up your W/E shading).

    Here's the formula that you wanted, in D3, copied across and down:

    =IF($A3="","",IF(D$1="","",IF(D$2="W",LOOKUP(2,1/($B$2:C$2="W"),$B3:C3)+1,LOOKUP(2,1/($B$2:C$2=""),$B3:C3)+1)))

    basically if the day is a W it looks for the last number corresponding to a W and adds one to it. Same for non-W. So, when you manually enter a zero the numbering system starts over.

    The salmon coloured shading (which is rather ugly) was applied manually just to show you the raneg currently covered by the formula and the CF.

    Don't forget that if it gets too wide and you want to reset the sheet, you'll need a new pair of pump priming columns AND you will have to copy/paste the formula again as you will ahve over-written some of the cells with a zero.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: Formula to add one to the previous column, with one exception

    That works great. Thanks.

    How about a Conditional Formatting that highlight the highest number in each column as well? Without having to set a new "Top/Bottom" rule for each column.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula to add one to the previous column, with one exception

    There's a problem with that. Yes, it can be done... but. Once you overwrite the max number with a zero, then another cell will become the maximum and will highlight. That sounds MESSY to me.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Formula to add one to the previous column, with one exception

    I'm looking at the workbook from post #4.

    Highlight D3:AZ20 (or however far you want to go) > Conditional Formatting > New Rule > Use a formula
    =D3=MAX($D3:$AZ3)
    Format: Fill color of your choice > OK > OK

  8. #8
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: Formula to add one to the previous column, with one exception

    I understand. Shortly after the max is identified and replaced with a zero, that column will be hidden. This just gives us the data needed to fill out a roster and then we hide it. Thanks again.

  9. #9
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: Formula to add one to the previous column, with one exception

    That only highlighted numbers in the last row with data (AJ). I need the highest number in each column to be highlighted. Thanks.

  10. #10
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: Formula to add one to the previous column, with one exception

    Didn't mean to post this additional replay and can't figure out how to delete it.
    Last edited by scheidc; 11-28-2018 at 01:04 PM.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula to add one to the previous column, with one exception

    Now hideable row 2 is blank until a date is entered. Then the MAX in the coluumn is displaced UNLESS there is a 0 in the column, in which case it's blank (see AJ2)....
    Attached Files Attached Files

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula to add one to the previous column, with one exception

    Pooh. I've just seen Post 9, but will wait for your reaction before firing off again.

  13. #13
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Formula to add one to the previous column, with one exception

    My mistake, I thought you said the highest number in each row.

    Change the formula from post #7 to this:

    =D3=MAX(D$3:D$20)

  14. #14
    Registered User
    Join Date
    02-06-2017
    Location
    US
    MS-Off Ver
    16
    Posts
    8

    Re: Formula to add one to the previous column, with one exception

    The formula from post #13 doesn't seem to be working either.

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula to add one to the previous column, with one exception

    But what about the one in Post 11??? i was waiting to hear from you.

  16. #16
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Formula to add one to the previous column, with one exception

    If you follow the instructions from post #7 using the formula in post #13, the largest number in each column will be highlighted.

+ 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] An IF formula who take account of the previous and next line of the first column.
    By Maximus620 in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 04-21-2015, 09:43 PM
  2. [SOLVED] Most common string in column with an exception
    By Bytor47 in forum Excel General
    Replies: 5
    Last Post: 04-11-2013, 07:46 AM
  3. Replies: 0
    Last Post: 09-04-2012, 10:05 PM
  4. Replies: 12
    Last Post: 06-06-2012, 01:43 PM
  5. Summing Column with exception
    By canberry in forum Excel General
    Replies: 6
    Last Post: 04-11-2009, 09:23 PM
  6. formula to return data from previous column
    By mheinmiller in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-19-2008, 10:26 AM
  7. Copying a formula in a blank column as far as data in previous column
    By basildon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2005, 11:35 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