+ Reply to Thread
Results 1 to 10 of 10

Compare 1 price against multiple prices and change the price according to a formula

  1. #1
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Compare 1 price against multiple prices and change the price according to a formula

    Hello everybody,

    Thank you so much for your previous and continuous help. I have an issue that I think it needs a sort of excel function but I don't know how to do it, I have a table, let's say columns D, I, J, K, L, M, N, O, P and they all have different prices, what I need to do is to compare the very first price in D2, against every other price cell, starting with I2, and see: if D2 is smaller than I2, then let D2 be = the price in I2 - 0.50 , otherwise, if D2 is larger than I2 within the limit of 2.50 (that is to say, larger with the amount from 0.001 to the amount 2.50), then let D2 be = the price of I2 - 0.20 , and if D2 is larger than I2 with more than 2.50, then totally leave I2, and compare the price in D2 against the price in the next cell which is J2, if D2 is smaller than J2, then let D2 be smaller than J2 with only 0.50 , otherwise if D2 is larger than J2 within the limit of 2.50 (that is to say, larger with the amount from 0.001 to the amount 2.50), then let D2 be = the price of J2 - 0.20 , and if D2 is larger than J2 with more than 2.50, then leave J2, and compare the price in D2 against the price in K2, .. and so on until the condition comes true
    After that it would be preferable to color the cell (I, J, K, L, M, N, O, P) where the condition comes true, with a red bold font or yellow highlight cell or .. etc

    Many thanks
    Charlie

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Compare 1 price against multiple prices and change the price according to a formula

    Pop up a sample workbook that has all this laid out already. Make sure the sample has 3-4 examples where you've mocked up the answers in column D manually and highlighted the match cells, if it's not obvious.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Compare 1 price against multiple prices and change the price according to a formula

    Hi JBeaucaire

    Thanks a lot. I attached a sample sheet. There are 2 more columns (Q, R) to consider as well.
    And the results will be calculated by the formula and placed in a new column, I would appreciate your recommendation.

    Many thanks
    Charlie
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Compare 1 price against multiple prices and change the price according to a formula

    Hello JBeaucaire,

    There is a little change in the required task, I rephrased the task:

    Columns D, I, J, K, L, M, N, O, P, Q, R and they all have different prices, what I need to do is to compare the very first price in D2, against every other price cell, starting with I2, and see: if D2 is smaller than I2, then let D2 be = the price in I2 - 0.50 , otherwise, if D2 is larger than I2, then totally leave I2, and compare the price in D2 against the price in the next cell which is J2, if D2 is smaller than J2, then let D2 be smaller than J2 with only 0.50 , otherwise if D2 is larger than J2, then leave J2, and compare the price in D2 against the price in K2, .. and so on until the condition comes true.
    After that it would be preferable to color the cell where the condition comes true within (I, J, K, L, M, N, O, P, Q, R), with a red bold font or yellow highlight cell or .. etc

    Many thanks
    Charlie

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Compare 1 price against multiple prices and change the price according to a formula

    You didn't indicate where you wanted this formula, so in F2 put this array formula:

    =IFERROR(INDEX(I2:R2, MATCH(TRUE, ($I2:$R2<$D2), 0))-0.5, $D2)

    ... confirmed by pressing CTRL-SHIFT-ENTER to activate the array. You will see curly braces { } appear around your formula to indicate an active array.

    The part in red is the array, it is running that formula over and over for each cell in $I2:$R2 to see if any of them are less then D2. If so, TRUE results there, and it will return that position back to the INDEX. The INDEX is the same cells, I2:R2, so it results in that number being returned. Then .50 cents is deducted and that's your answer.

    If none of the cells is less then D2, it results in an error, and the IFERROR converts the error back into the D2 as the default price.

    After entering the formula as an array in cell F2, copy F2 down as needed.

  6. #6
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Compare 1 price against multiple prices and change the price according to a formula

    Dear JBeaucaire,

    I tried your formula, in S, but it gives the same values in D.
    Attached is a clearer sample with the desired results in S

    Thank you in advance
    Charlie
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Compare 1 price against multiple prices and change the price according to a formula

    OOPS, read the operator wrong, switch the < to >.

    =IFERROR(INDEX(I2:R2, MATCH(TRUE, ($I2:$R2>$D2), 0))-0.5, $D2)

  8. #8
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Compare 1 price against multiple prices and change the price according to a formula

    Dear JBeaucaire

    Thank you so much for your help, now it worked, I am truly grateful and appreciate that. Have a wonderful day.

    Charlie

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Compare 1 price against multiple prices and change the price according to a formula

    @ CharlieAziz

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as an infrequent user of the forum, you may have forgotten (or may not be aware) that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  10. #10
    Registered User
    Join Date
    09-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Thumbs up Re: Compare 1 price against multiple prices and change the price according to a formula

    Dear Cutter,

    Thank you for taking care of this. I already submitted a thanks approval after I clicked on the star, and I was just leaving the page open to continue all necessary actions then I just got busy with something, but I will take more care next times, and I appreciate your help. Have a wonderful day.

    Charlie

+ 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