+ Reply to Thread
Results 1 to 26 of 26

Finding Min/Max and subtracting or adding based on condition

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Finding Min/Max and subtracting or adding based on condition

    Hi Everyone,
    Hoping someone can help me out with this. I have a string of values such as the below:

    12 1 2 2 3 2 2 1 13

    In my template the first value is always the number you hard code in and the rest are formulas which refer to percentages from another sheet and disperse the ttl amount of units. Because this reads off of another page of percentages the last number (due to rounding) usually is not the same as the first number you enter. Normally, I would go back take one unit away from the greatest value (aka 3) and make it a 2......now the first number and last number equal 12.

    12 1 2 2 2 2 2 1 12

    I want to add a formula which will identify FIRST if the first and last number equal each other. NEXT, if the first number is less than the second number I want to subtract 1 unit from the highest value (MAX) in the sequence (aka the 3 above was changed to a 2). Also, if the first number is more than the second number I want to add one unit to the 4th value in. LAST, I want the last number to be updated to the new total units.

    I was thinking I could maybe use a nested if/min/max/replace formula but I keep getting stuck. Can anyone help me out with this?? Thanks so much!!

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Finding Min/Max and subtracting or adding based on condition

    maybe a sample file and the formulas you've used to come up with the strings...
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    The strings are populated from a vlookup to the prior sheet with percentages on it. Nothing really complex.....do you still want to see the whole file? Thanks!!

  4. #4
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Please see the attached
    Attached Files Attached Files

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

    Re: Finding Min/Max and subtracting or adding based on condition

    well i've had to guess a couple of things but maybe........
    Attached Files Attached Files
    "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

  6. #6
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Thank you for helping! I was using a similiar formula as well. Two issues arise with the formula you used.....3 may not always be the highest number in the string. Many times this number can go up to 10. Additionally, in many cases there are multiple 3's in the string or multiples of the highest value. In an ideal world I would like to subtract from the first greatest value. Any further ideas?


    Thanks again!!

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

    Re: Finding Min/Max and subtracting or adding based on condition

    ok stab no 2
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    This looks awesome!!!!!!!!!!!!!!!! So just to verify.....you can now enter any number and if the first number is lower than the last it will subtract from the first largest value (even if there are multiples of the largest value). Also, is there anyway we can make sure when there are units subtracted it never will fall to a 0?

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

    Re: Finding Min/Max and subtracting or adding based on condition

    now thats a different thing,where would you want to subtract it from instead
    take 6 1111111 7 for example
    thats the only type i can think of that would fall to 0

  10. #10
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Right that was the only instance i can think of that occuring as well. Is there any way in that specific occasion we can simply not drop anything? I want minimum values of 1 at all times. If not no big deal just wanted to hear your thoughts. Your're great at excel what did you study?

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

    Re: Finding Min/Max and subtracting or adding based on condition

    self taught, but since if all1's then max will be first 1 so add an if condition in column N
    =IF(AND($I1>$A1,MATCH(MAX($B1:$H1),$B1:$H1,0)=COLUMNS($A$1:A$1)),IF(B1-1=0,1,B1-1),B1)
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    I'm not sure why it's not coming out correctly. Would you be able to help once more?
    Attached Files Attached Files

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

    Re: Finding Min/Max and subtracting or adding based on condition

    do it again but put all the data on one sheet,it's easier to see what's going wrong

  14. #14
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    I've tried to re-create the same thing on my read page as I did on my worksheet tab. The formulas are starting to stump me though. I used the same formula but now its not pulling in the numbers. Would you be able to take a look at the attachment?
    Attached Files Attached Files

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

    Re: Finding Min/Max and subtracting or adding based on condition

    get the value errors fixed first eg in N9 =MROUND($D9*(VLOOKUP($A9,'read sheet'!$I:$AS,N$5,FALSE)/100)) this bit is giving a value error
    thats because VLOOKUP($A9,'read sheet'!$I:$AS,N$5,FALSE) is returning "A " you can't round text!

  16. #16
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    I'm confused......so on my attachment I am looking at X20 on the "read" sheet tab. I'm trying to correct this formula bc you wanted to see everything on one page. The correct formula already exists on the "worksheet" tab E9-K9 but i do not understand why it is returning N/A's in X20 on the "read sheet" tab. Would you help me correct this formula? I have gone over it many times and I'm confused.



    Thanks again!

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

    Re: Finding Min/Max and subtracting or adding based on condition

    =VLOOKUP($A20,$I:$S,X$16,FALSE) is giving the error there is nothing in a20

  18. #18
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Fixed it!! Please see the attached now.....all formulas are on one sheet but the new min/max formula is not correcting the initial paste. Let me know your thoughts.


    Thanks!!
    Attached Files Attached Files

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

    Re: Finding Min/Max and subtracting or adding based on condition

    the formulas in column AL are different from the rest you cant just drag/fill AI across , also you never made the amendment to column AI as pointed out in post#11
    ok i've changed them now and it works
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Thanks again!
    Would I be able to copy the first whole line ( Ex: from W20 to AE 20) and then paste special formulas to the lines below? I need the formula to cover many more lines.

  21. #21
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    Also in col AG why is there the word FALSE with two 3's underneath it?

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

    Re: Finding Min/Max and subtracting or adding based on condition

    you can select w20:ae20 and use the fill handle to drag down all at once
    delete those odd bits i was just testing your formulas
    Last edited by martindwilson; 07-25-2012 at 03:04 PM.

  23. #23
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    fill handle? I usually just copy and paste special formulas.....whats the fill handle?

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

    Re: Finding Min/Max and subtracting or adding based on condition


  25. #25
    Registered User
    Join Date
    07-10-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Finding Min/Max and subtracting or adding based on condition

    In column AG why does it say false and two number 3's underneath it? It doesn't look like anything is reading off of this. Should i leave this there?

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

    Re: Finding Min/Max and subtracting or adding based on condition

    i did say at post #22 delete those

+ 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