+ Reply to Thread
Results 1 to 14 of 14

Better way to write a sum IF formula?

Hybrid View

  1. #1
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35

    Better way to write a sum IF formula?

    Hello all,

    I basicaly need to look down column Q8 to Q52 for the falue "C19"
    If that value is present - Then I need to look up the value of associated
    with what is in its respective cell in column O8 to O52.
    Then add them all together.

    I have the formula that follows and it works, however it is huge. I have to repeat the IF,Vlookup 44 times. Just wondering if there is a better way.

    Here is the formula I am using.

    =SUM((IF(Q8="C19",(VLOOKUP(O8,clusterequipmentvalues,2,FALSE)),0)),
    (IF(Q9="C19",(VLOOKUP(O9,clusterequipmentvalues,2,FALSE)),0)),
    (IF(Q10="C19",(VLOOKUP(O10,clusterequipmentvalues,2,FALSE)),0)),
    (IF(Q11="C19",(VLOOKUP(O11,clusterequipmentvalues,2,FALSE)),0)),
    (IF(Q12="C19",(VLOOKUP(O12,clusterequipmentvalues,2,FALSE)),0)),
    .... all the way to C52.


    Thanks for the help.

    -Lee

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446
    Hi,

    Try this?

    =SUMIF(Q8:Q52,"C19",O8:O52)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671
    or
    =SUMPRODUCT(--IF(Q8:Q52=C19,O8:O52))
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35
    Thanks for the quick replys. However this will not work as the column 08 to 052 does not include the values that need to be sumed but a value that is looked up from the table cluster equipment values.

  5. #5
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35
    I have enclued a attachment with a sample of what I am looking for.
    Attached Files Attached Files

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Maybe don't understand your example, but the formulas that appear to give you want you want are simple COUNTIF functions.
    i14 =COUNTIF(C6:C8,"C19")
    i15 =COUNTIF(C6:C8,"C13")
    _________________
    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!)

  7. #7
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35
    countIF would work if all the each piece of equipment had the same number or connections.

    If you look at the example you can see that.

    each equipment has eather a C19 or a C13 connecter type.
    each equipment has a varied number of connections.

    I use vlookup to determin what type of connection
    and vlookup to determin how many of thoes connections there are

    I need a formula that will add the number of connections there are based on the type of connection.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    So you really want those numbers in D:D, not the count of how many C19s there are? This does that:
    i14 =SUMIF(C6:D8,"C19",D6:D8)
    i15 =SUMIF(C6:D8,"C13",D6:D8)

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Also, on the final implementation, I would name the data ranges C6:D8 to INLETS and D6:D8 to CONNECTS and then the formula is even easier to read in a HUGE sheet:

    =SUMIF(INLETS,"C19",CONNECTS)

  10. #10
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Better way to write a sum IF formula?

    Using your posted workbook....and these Range Names:
    RangeName...............Refers To
    ClustEquip..............=Sheet1!$B$6:$B$8
    CONNECTS................=Sheet1!$D$6:$D$8
    INLETS..................=Sheet1!$C$6:$C$8
    Then....
    I14: =SUMPRODUCT(COUNTIF(I6:I10,ClustEquip)*(INLETS="C19")*CONNECTS)
    and
    I15: =SUMPRODUCT(COUNTIF(I6:I10,ClustEquip)*(INLETS="C13")*CONNECTS)
    Those formula return: 20 and 4, respectively.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  11. #11
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35
    That is correct I need the number is D:D however I need to look up thoes numbers and sum them baised on what is in column I:I using the named array clusterequipmentvalues

    I:I 's values are inputed with a list (Data valadation)

    They can have more than one of each type of equipment.

    So I need to look up its inlet type and how many for each entry. Add up the total for each type for all the equipment listed.
    Last edited by leewcrawford; 11-05-2008 at 01:44 PM.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Well, I'm sure it's clear to you what the list of words in I6:I10 is doing, but it's not to me. Sorry. To me, it just looks like a list of unrelated words.

    I see your formula sample below is coming up with the number 20. How is that correct? What do all of these things mean in the real world that make 20 the right answer?

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Ron, I see how he gets 20 now. Duh! Thanks for that!

  14. #14
    Registered User
    Join Date
    09-03-2008
    Location
    Dallas Texas
    Posts
    35
    Perfection Ron! That works great.

    Thanks so much everyone for the help.

    -Lee

+ 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