+ Reply to Thread
Results 1 to 5 of 5

Return 1 if sum of adjacent matching cells equals zero

  1. #1
    Registered User
    Join Date
    03-09-2016
    Location
    Johannesburg, South Africa
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Return 1 if sum of adjacent matching cells equals zero

    Hi all,

    I'm working on a project at work, that looks at the movement of stock in and out of a warehouse. I'd only like to count a Pallet ID if the sum of its movements equals zero, else a zero must be shown. See below for an example:

    Pallet No Movement Calculation
    14555 -10 0
    14555 20 0
    14555 20 0
    14555 -30 1
    14777 10 0
    14777 -10 1

    Any ideas on how this would be achieved? Any help would be greatly appreciated.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return 1 if sum of adjacent matching cells equals zero

    Maybe this...

    Data Range
    A
    B
    C
    1
    ------
    ------
    ------
    2
    14555
    -10
    0
    3
    14555
    20
    0
    4
    14555
    20
    0
    5
    14555
    -30
    1
    6
    14777
    10
    0
    7
    14777
    -10
    1


    This formula entered in C2 and copied down:

    =--(SUMIF(A$2:A2,A2,B$2:B2)=0)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Return 1 if sum of adjacent matching cells equals zero


    A
    B
    C
    1
    Pallet No
    Movement
    Calculation
    2
    14555
    -10
    =1*(SUMIF($A$2:$A2,$A2,$B$2:$B2)=0)
    3
    14555
    20
    4
    14555
    20
    5
    14555
    -30
    6
    14777
    10
    7
    14777
    -10


    Drag it down to C7. It'll look neater if you sort Column A
    (copy pasta from Ford)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools

    Regards,
    Lem

  4. #4
    Registered User
    Join Date
    03-09-2016
    Location
    Johannesburg, South Africa
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Re: Return 1 if sum of adjacent matching cells equals zero

    That worked perfectly Tony, thanks!

    Could you please give me some detail into why that worked? I'm still a little new here.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return 1 if sum of adjacent matching cells equals zero

    The formula does a progressive SUMIF on each row of data.

    SUMIF(A$2:A2,A2,B$2:B2)=0 returns either TRUE or FALSE.

    Then the double unary minus -- converts that to 1 or 0.

    --(SUMIF(A$2:A2,A2,B$2:B2)=0)

    --TRUE = 1
    --FALSE = 0

+ 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. [SOLVED] If a cell in a column equals today's date return the value of another cell adjacent to it
    By DeanExcel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2021, 01:38 AM
  2. Replies: 9
    Last Post: 09-30-2014, 09:10 AM
  3. Return a value when another cells equals certain text
    By CCSFM Excel2007 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-08-2014, 04:23 AM
  4. Replies: 2
    Last Post: 09-07-2013, 07:50 PM
  5. [SOLVED] return the sum of cells within a range only if neighboring cell equals preset value
    By skittlejr in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-02-2013, 11:03 PM
  6. [SOLVED] Return value if any of cells in range equals a specific value (cell)
    By G.Bregvadze in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-30-2013, 07:59 AM
  7. Replies: 2
    Last Post: 06-12-2012, 06:39 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