Adding two formula's together in one cell?

Anonymous
2011-11-06T19:38:01+00:00

I'm now working on a separate work book for our ebay sales, and in one of the cells that outputs the insertion fee is the following:  (Be gentle with me lol, if I've done this the wrong way or it's over winded and could have been done simpler :)  Any way it pulls the insertion fee's from another sheet so that if at a later date they put them up I can just start a new workbook and alter the fee's in that one sheet, but the problem is we sometimes list the same item in two categories so in theory our insertion fee is doubled, so to get around this I have added another column , so now have:  one column with Category One P10, and column two with Category Two R10,  in cell Z10 is the total insertion fee.  But at the moment it just shows the fee's for Category One P10how can I also use the same formula but just add them together?

=IF(AND(N10="Auction",P10="All Categories",T10>=0.01,T10<=0.99),'_Settings'!$M$8,IF(AND(N10="Auction",P10="All Categories",T10>=1,T10<=4.99),'_Settings'!$M$9,IF(AND(N10="Auction",P10="All Categories",T10>=5,T10<=14.99),'_Settings'!$M$10,IF(AND(N10="Auction",P10="All Categories",T10>=15,T10<=29.99),'_Settings'!$M$11,IF(AND(N10="Auction",P10="All Categories",T10>=30,T10<=99.99),'_Settings'!$M$12,IF(AND(N10="Auction",P10="All Categories",T10>=10),'_Settings'!$M$13,IF(AND(N10="Auction",P10="Media Related",T10>=0.01,T10<=0.99),'_Settings'!$M$15,IF(AND(N10="Auction",P10="Media Related",T10>=1),'_Settings'!$M$16,IF(AND(N10="Buy It Now",P10="All Categories"),'_Settings'!$AC$10,IF(AND(N10="Buy It Now",P10="Media Related"),'_Settings'!$AC$11,""))))))))))

Many many thanks in advance for any help, I'm very grateful.

Linda

PS the work book is so that I can see what fee's we are paying and our profit after fees, and so adjust accordingly.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2011-11-07T10:01:34+00:00

Linda wrote:

Cheers Joe,  here's the linkhttp://www.lindaoraya.talktalk.net/eBay Sales WorkBook.zip

Thank you Joe, still haven't got to bed as yet.  Daughter is ill so, looks like it's going to be a long night :(

Hope you and your daughter managed to get some sleep.

In the meantime, I had a chance to review your past explanations and look at your uploaded file.  I realized that I had misunderstood some of the intended design, mostly due to my ignorance of eBay.

I have uploaded a file with some changes (click here).  That file is an Excel 2003 file.

The primary change is in column Z.  The formula is a correction to my previous efforts, to wit:

=IF(OR(N10="",AND(P10="",R10=""),T10=""), "",

IF(N10="Buy It Now",

IF(P10="",0,IF(P10="All Categories",_Settings!$AC$10,_Settings!$AC$11))

+IF(R10="",0,IF(R10="All Categories",_Settings!$AC$10,_Settings!$AC$11)),

IF(P10="",0,IF(P10="Media Related",

IF(T10<1,_Settings!$M$15,_Settings!$M$16),VLOOKUP(T10,_Settings!$G$8:$M$13,7)))

+IF(R10="",0,IF(R10="Media Related",

IF(T10<1,_Settings!$M$15,_Settings!$M$16),VLOOKUP(T10,_Settings!$G$8:$M$13,7)))))

A significant change is:  you do not need the table I suggested in X1:Y6.  Your existing table in _Settings!$G$8:$M$13 will suffice.

I suspect that the values in P10 and R10 are mutually exclusive if both are specified.  That is, if P10 is "All Categories", I suspect that R10 is "Media Related" or empty; and vice versa.  I also suspect that P10 will never be empty when R10 is non-empty.  That is, you always use Category 1 first and only optionally also use Category 2.

Those observations might lead to some simplification of the formula.  But I suspect only minor simplifications; for example, we probably do not need IF(P10="",0.  But we still need IF(R10="",0.

If you confirm the observations above, I could look to see how much we can simplify the formula, if you wish.  But I think it works well as is, and I suspect it is not overly complicated.

Note that I also made a number of other minor improvements in some unrelated formulas.

  1. I simplified the SUM formulas in C4 and G4.  Note that SUM can have at least as many as 30 parameters (XL2003 limit).  XL2007 might permit more.  I don't know.
  2. I simplified the IF formulas in columns AP, AR and AZ.  Let me know if you have any questions.  In general, it is not necessary to test both of two complementary conditions.  The change in column AZ also includes an arithmetic simplification.
  3. I changed the lower limits in G8 and G15 in the _Settings worksheet from 0.01 to 0.00.  That also required a format change for 0 values (3rd field).  Although column T in the "eBay Sales" worksheet might never be zero, it is better to have 0.00 in the lookup table for technical reasons.  "Defensive programming".  Nevertheless, if you insist on 0.01, it probably will work that way.

Hope that helps.

[EDIT] PS:  I forgot to mention a change that I did not make.  I noticed some content in T1011:U1017 in the "eBay Sales" worksheet.  I'm not sure what they are doing there; I did not find any formulas dependent on that data.  I suspect it should be removed.

Was this answer helpful?

0 comments No comments

43 additional answers

Sort by: Newest
  1. Anonymous
    2011-11-08T01:43:55+00:00

    Linda wrote:

    I'm sorry not sure if I'm just being really dense tonight or it's the lack of sleep

    Perhaps the latter.  Or perhaps it is I who does not understand what you are not getting.  Forgive me if the following completely misses the target and belabors what you already know.

    Note:  Ordinarily, I might suggest that you use the Evaluate Formula feature of Formula Auditing.  But at least in XL2003 SP3, Excel bellies up for unknown reasons when using EF to step through the evaluation of this construct.

    Linda wrote:

    I understand everything (well sort of) up until it selects the correct fee for price related listings as in the Auction fees for All Categories!  I mean how does it know which is the correct fee?  [....] can you pretend you're explaining it to a 10yr old :)

    I think you are saying that you do not understand how VLOOKUP(T10,_Settings!$G$8:$M$13,7) works.  Or are you saying you do not understand how the nested IFs even get to the VLOOKUP?

    For the operation of the nested IFs, I will use the "v1" construct.  Conceptually, the "v2" SUM array formula is simply a compact way of expressing the same thing.

    Part of the problem with understanding the nested IFs might be the formatting.  Does the following pseudocode make it any clearer?

    IF(N10="Buy It Now",

        IF(P10="",

            0,

            IF(P10="All Categories", _Settings!$AC$10, _Settings!$AC$11))

        +IF(R10="",

            0,

            IF(R10="All Categories", _Settings!$AC$10, _Settings!$AC$11)),

    //else N10="Auction"

        IF(P10="",

            0,

            IF(P10="Media Related",

                IF(T10<1, _Settings!$M$15, _Settings!$M$16),

            //else P10="All Categories"

                VLOOKUP(T10,_Settings!$G$8:$M$13,7)))

        +IF(R10="",

            0,

            IF(R10="Media Related",

                IF(T10<1, _Settings!$M$15, _Settings!$M$16),

            //else R10="Categories

                VLOOKUP(T10,_Settings!$G$8:$M$13,7)))))

    Of course, //else is not really part of the Excel syntax.

    Alternatively, does the following PHP pseudocode make it clear?

    if (N10=="Buy It Now")

        {

        if (P10=="")

            p = 0;

        elseif (P10=="All Categories")

            p = _Settings!$AC$10;

        else  // P10=="Media Related"

            p = _Settings!$AC$11));

        if (R10=="")

            r = 0;

        elseif (R10=="All Categories")

            r = _Settings!$AC$10;

        else // R10="Media Related"

            r = _Settings!$AC$11));

        return p+r;

        }

    else // N10="Auction"

        {

        if (P10=="")

            p = 0;

        elseif (P10=="Media Related")

            {

            if (T10<1)

                p = _Settings!$M$15;

            else

                p = _Settings!$M$16);

            }

        else // P10=="All Categories"

            p = VLOOKUP(T10,_Settings!$G$8:$M$13,7);

        if (R10=="")

            r = 0;

        elseif (R10=="Media Related")

            {

            if (T10<1)

                r = _Settings!$M$15;

            else

                r = _Settings!$M$16);

            }

        else // R10=="All Categories"

            r = VLOOKUP(T10,_Settings!$G$8:$M$13,7);

        return p+r;

        }

    For the operation of  VLOOKUP(T10,_Settings!$G$8:$M$13,7), conceptually it works as follows.  In the _Settings worksheet, you have the following table:

              G        M

    8:      0         0.00

    9:      1         0.15

    10:    5         0.25

    11:    15       0.50

    12:    30       1.00

    13:    100    1.30

    Imagine how you might look up the value of T10 in column G, then look across to get the corresponding value in column M.

    1. If T10>=100, return 1.30
    2. Elseif T10>=30, return 1.00
    3. Elseif T10>=15, return 0.50
    4. Elseif T10>=5, return 0.25
    5. Elseif T10>=1, return 0.15
    6. Elseif T10>=0, return 0.00
    7. Else return #N/A error

    VLOOKUP does a ">=" test here because I did not specify a 4th parameter; ergo, the 4th parameter defaults to TRUE, which means "match approximate value" instead of "exact value".  For this kind of lookup, column G must be in ascending order.  And it is.

    Note:  In fact, VLOOKUP is presumed to be more efficient than that.  It probably performs a binary search [1], much like you might do if you looked up a word in the OED.

    Does this help?  Or should we ask your daughter to study this, then explain it to you? :-) :-)


    [1] I actually "proved" that VLOOKUP does indeed use a binary search when the last parameter is TRUE or omitted by testing VLOOKUP with carefully constructed out-of-order lookup tables.  Normally, in that case, the results are unreliable.  But knowing how a binary search algorithm should be implemented, I was able to control what results were returned for various lookup values.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-11-07T22:29:39+00:00

    I'm sorry not sure if I'm just being really dense tonight or it's the lack of sleep, I understand everything (well sort of) up until it selects the correct fee for price related listings as in the Auction fees for All Categories!

    I mean how does it know which is the correct fee?  I'm so sorry if you're going over it lol..  can you pretend you're explaining it to a 10yr old :)

    Linda

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-11-07T21:36:21+00:00

    Linda wrote:

    The merged columns where so I could position exactly the Totals at the top of the document. I know I'm pedantic hehehe.. I like everything to LOOK perfect! What am I like? :) 

    Not I !! :-)

    Seriously....  I did see that.  But since the totals at the top were aligned on the left with pairs (or quads) of columns, you should be able to get the same effect (or close enough) simply by "doubling" the width of individual columns.

    The original columns widths were 6.  When I tried a column width of 12, the text was clipped on the left.  So I simply use a column width of 13; 1 character-width to account for the cell border.

    Again, study my "v2" of the file that I uploaded.

    PS:  Aha!  It is true that the totals on the upper right we aligned starting in column U, midway between the merged pair T:U.  I think the operative word is "close enough".  Even perfectionists like us need to choose reasonable compromise occassionally. :-)

    The real point is:  this will be come a "necessary" step if you want to adopt my design for supporting more than two categories (TBD).

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-11-07T21:26:20+00:00

    Will do it now.

    Linda

    Was this answer helpful?

    0 comments No comments