+ Reply to Thread
Results 1 to 6 of 6

Importing cell values into formulas & SUMIF/PRODUCT formulas with 2 conditions

  1. #1
    Registered User
    Join Date
    03-24-2008
    Posts
    14

    Importing cell values into formulas & SUMIF/PRODUCT formulas with 2 conditions

    These questions expand on a previous thread of mine, in which I received excellent help: http://www.excelforum.com/showthread.php?t=639775

    To shortly summarize that thread, I now have a formula that adds together the values in column B for rows that are labeled "X" in column A, so that for example the setup...

    A B
    X 1
    Y 1
    Z 1
    X 2

    ...would return 3 if the condition is defined as "X". The formula looks like this:

    =SUMPRODUCT(--(OFFSET($A$2;0;0;COUNTA($A:$A);1)="X")*OFFSET(B$2;0;0;COUNTA($A:$A);1))

    (After implementing the above solution I've been told the simpler formula =SUMIF(A:A,"X",B:B) does the same thing, though I have yet to try it.)

    Questions:

    (1) Is it possible to make the condition "X" be drawn from a cell value - say D2 - so that when I change the value in D2 from "X" to "Y", this change is reflected in all formulas that refer to D2?

    (2) How do I add another condition to either formula above so that it only adds the values in column B for all rows that are labeled "X" in column A and "Z" in column C?

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Answer 1. Yes, just replace "X" with your cell (e.g. A1).

    Answer 2. Add a term to your SUMPRODUCT for it to look at Column C for "Z" like so;
    Please Login or Register  to view this content.
    You can replace "Z" with another cell location also.

    Work for you?

    ChemistB

  3. #3
    Registered User
    Join Date
    03-24-2008
    Posts
    14
    Works perfectly, thank you!

    I must have put quotation marks around A1 when I tried simply referencing the cell.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Glad to hear you got it working. Thanks for the feedback.

    ChemistB

  5. #5
    Registered User
    Join Date
    03-24-2008
    Posts
    14
    After some further testing I've run into a problem.

    If I use the autofilter function with two conditions in the formula it will mess up the calculation, e.g. if I sort by 'Ascending' it will yield different result than if I sort by 'Descending'. Autofilter works fine with just one condition. Is there something I can do with the formula to allow use of the autofilter function?

  6. #6
    Registered User
    Join Date
    03-24-2008
    Posts
    14
    Bump, no response.

+ 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