+ Reply to Thread
Results 1 to 9 of 9

Calculate cells if other cell contains a value - Need help with the logic.

  1. #1
    Registered User
    Join Date
    07-06-2012
    Location
    nh
    MS-Off Ver
    Excel 2003
    Posts
    36

    Calculate cells if other cell contains a value - Need help with the logic.

    I am trying to calculate a series of cells but only if adjacent cells contain data. I can't think of the right formula for this. If someone could lead me in the right direction I should be able to do the rest I just can't think of the right one.

    Here is the example. Cells A1, C1, E1, and G1 contain Sales dollars where B1, D1, F1, H1 contain the Budget. In I1 I have the running total for sales. In J1 I want to sum each of the budget dollars but only if there is a value in the sales dollars cell next to it.

    To sum it up I think this is what I am looking for: SUM B1(if A1 > 0), D1(if C1 > 0), F1(if E1 > 0), H1(if G1 > 0)

    I hope this makes sense.

    thanks in advance.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,463

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Please post a sample sheet - Thx

  3. #3
    Registered User
    Join Date
    07-11-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    =SUM(IF($A1<>"",$B1,0),if($C1<>"",$D1,0),if($E1<>"",$F1,0),if($G1<>"",$H1,0))

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Is that a REAL example of what you want, or a simplified version of something more complicated?

    It's usually best to post a real world example of what you want, using the actual cell references and values.
    Because the solution to the simplified version is often very difficult to adapt to the real version of the issue.
    Last edited by Jonmo1; 07-08-2013 at 08:48 AM.

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Try

    =SUMPRODUCT(B1:H1,--(A1:G1<>""),--(MOD(COLUMN(B1:H1),2)=MOD(COLUMN(B1),2)))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  6. #6
    Registered User
    Join Date
    07-06-2012
    Location
    nh
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Quote Originally Posted by Ferloft View Post
    =SUM(IF($A1<>"",$B1,0),if($C1<>"",$D1,0),if($E1<>"",$F1,0),if($G1<>"",$H1,0))
    Perfect, thank you. I was close, I appreciate the help.

  7. #7
    Registered User
    Join Date
    07-06-2012
    Location
    nh
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Now I implemented this into the project and realized it won't work because where there are blanks there are actually #N/A values because I have it pulling data with VLOOKUP. Normally I would use the aggregate function to calculate in a case like this but I couldn't get the aggregate function to work with the IF function. I would appreciate any help with this.

  8. #8
    Registered User
    Join Date
    07-06-2012
    Location
    nh
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Here is a quick example sheet if this helps.. Thank you. Formula.xlsx

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Calculate cells if other cell contains a value - Need help with the logic.

    Probably best off to adjust your vlookups so they don't return #N/A errors

    =IFERROR(VLOOKUP(...),0)

+ 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