+ Reply to Thread
Results 1 to 12 of 12

Finding 2 cells >0

  1. #1
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Finding 2 cells >0

    Is it possible to build a function that sums 2 cells in a row with values larger than 0? I want the function to sum like the example below with the numbers mixed with the 0 on the left side and the row on the right that I want to find a function to:


    0 0
    1 0
    2 0
    0 3
    0 3
    3 3
    4 5
    0 7
    0 7
    5 7
    0 9
    0 9
    6 9
    ' 11
    Last edited by basset87; 02-12-2016 at 11:35 PM.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Finding 2 cells >0

    both have to be larger or either has to be larger than 0?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Finding 2 cells >0

    the more I think about this the more I am leaning toward any of these three...
    =IF(AND(A1>0,B1>0),SUM(A1:B1),"") - for both greater than zero
    =IF(OR(A1>0,B1>0),SUM(A1:B1),"") - for either greater than zero
    =SUM(A1:B1) - just takes care of the whole mess.
    or =A1+B1

  4. #4
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Re: Finding 2 cells >0

    This is the row that I got as dataset:
    0
    1
    2
    0
    0
    3
    4
    0
    0
    5
    0
    0
    6

    or if it will make it easier I can transform the 0 values to -:

    -
    1
    2
    -
    -
    3
    4
    -
    -
    5
    -
    -
    6


    And now I want to find a function that sums the 2 nearest cells with a value in this dataset and sum it in the row with the function as the 2 rows in the previous post

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Finding 2 cells >0

    first I think you are confusing rows with columns. so in your post #4 what do you want done with - 5 - should it be ignored since there is no value above or below it? What would the results for what you posted be?

  6. #6
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Re: Finding 2 cells >0

    Yes, I meant columns. In that example with -5- I want the function to sum that number with the number 4 as those are the 2 nearest numbers. I want the function to ignore all non numbers/zero values and sum the 2 nearest numbers-

  7. #7
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Re: Finding 2 cells >0

    So I want the function column will look like this:
    0
    0
    3
    3
    3
    5
    7
    7
    7
    9
    9
    9
    11

  8. #8
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Finding 2 cells >0

    if your first column is in A1 down then put this in B3 and drag down.

    =IF(COUNTIF($A$1:A2,">0")>1,IF(A2=0,B2,A2+MAX($A$1:A1)),0)

    This only works though if your data is in ascending order like your example
    Happy with my advice? Click on the * reputation button below

  9. #9
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Re: Finding 2 cells >0

    The data are random numbers, but the formula works fine for this example, thanks. Is it possible to apply a formula that doesn't take any regards if the data is ascending or not?

    Is it possible to solve this problem in another way by first deleting all the cells in the column if a cell=0 as this example (https://www.youtube.com/watch?v=6_Ysi1SB9cY). That will make it easier to just sum up the 2 values by using the formula =sum(A1:A2), then go back to how the original column looked like and fill in all the cells where there used to be 0 with blanks so I will have the same number of cells in the column as to before the action of deleting cells.

  10. #10
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Finding 2 cells >0

    Give this a try in B3 again but after copying and pasting hit control + shift + enter as its an array formula then drag it down column B

    Please Login or Register  to view this content.
    it looks long and complicated but the reality is the black bit below does all the work and the red section is only to ensure you get a zero in the first few rows until you get two numbers to add together

    Please Login or Register  to view this content.

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,608

    Re: Finding 2 cells >0

    If your data starts in A1 try thi from B3 to the end:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will work in any order.

  12. #12
    Registered User
    Join Date
    02-12-2016
    Location
    Sliema, Malta
    MS-Off Ver
    Excel
    Posts
    6

    Re: Finding 2 cells >0

    Thanks BIG time!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding if all cells are the same value
    By neil40 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-04-2011, 08:11 AM
  2. Finding a value >30 in different cells
    By Cygnos in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-30-2007, 10:46 AM
  3. Replies: 3
    Last Post: 03-02-2007, 07:13 AM
  4. Finding * in cells
    By philtyler in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-03-2006, 01:14 PM
  5. Finding Cells
    By C. Brown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-29-2006, 04:40 AM
  6. Finding days between cells C and L where the cells may be empty
    By Jack in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2006, 02:50 PM
  7. [SOLVED] Finding Cells
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2005, 12:05 PM

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