+ Reply to Thread
Results 1 to 9 of 9

Reduce subtract a value in a column if a value repeats in another column

  1. #1
    Forum Contributor
    Join Date
    06-08-2021
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    101

    Reduce subtract a value in a column if a value repeats in another column

    Hi Guys,

    I apologize if the Title is confusing as I didn't know how to explain the situation better in one line.

    I have attached a sample file in which I have the columns, A, B, D, E, F, L and M. The first cell in F should check if M<D, if TRUE, it should return E+L-B, else E-B. But going downwards in Column F, the formula should check if values in Column A are repeating and if they are repeating it should first do the math E-B (Value in B should be from its previous usage) and then do the math similar to how it did before ( if M<D, if TRUE, it should return E+L-B, else E-B )

    For ex: in the attached file, 102 is a value in Column A that repeats three times with an initial On Hand of 10 (Column E). It is being used in three different jobs 301, 306, 304 in Column C. So, in column F when the formula does the math, it will return 5 (as 5 parts are used in the job 301). Then as we down in Column F, when 102 appears again, it should consider that it now only has 5 On Hand because the other 5 is already used. Then it can do the math for M<D, if TRUE, it should return E+L-B, else E-B.

    I tried my best to explain the situation above. If you guys think it is still not clear and have any questions, please feel free to ask.

    Any help is appreciated

    Thanks

    VJ
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Reduce subtract a value in a column if a value repeats in another column

    Your explanation is out of sync with the workbook, "sheet data"
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    06-08-2021
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    101

    Re: Reduce subtract a value in a column if a value repeats in another column

    Quote Originally Posted by protonLeah View Post
    Your explanation is out of sync with the workbook, "sheet data"

    My Apologies. Here is the correct file.

    VJ
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Reduce subtract a value in a column if a value repeats in another column

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    copied down.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    06-08-2021
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    101

    Re: Reduce subtract a value in a column if a value repeats in another column

    Hi Trevor,

    Thanks for the response. I tried the formula but it doesn't take into account that part#102 initially has On Hand Qty of 10 and after 5 of them being used in Job#301 , it is still considering it as 10 for Job#306. (where as it should be 5). That is the logic I'm trying to apply here.


    VJ

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,180

    Re: Reduce subtract a value in a column if a value repeats in another column

    Try

    in F2

    =SUMIF($A$2:A2,A2,$E$2:E2)-SUMIF($A$2:A2,A2,$B$2:B2)+IF(M2<D2,SUMIF($A$2:A2,A2,$L$2:L2),0
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  7. #7
    Forum Contributor
    Join Date
    06-08-2021
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    101

    Re: Reduce subtract a value in a column if a value repeats in another column

    Hi JOhn,

    Appreciate the help. I am still not getting the expected output. I think my explanation is confusing. So first step for me is to calculate and return Remaining OH quantity (for now, lets ignore comparing Column M and Column D). For ex: Part# 102 repeats three times in three different jobs. Their current OH in Column E is 10 (not 30 as they are duplicates because they are being used three time in different jobs). This current OH will change because the Part# 102 is used first in Job 301 (5 qtys used). So, when it gets to job 306 the Total OH should change to 5 as 5 of them have already been used and so on.

    I hope that makes sense. Please let me know if you have any questions

    VJ

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,548

    Re: Reduce subtract a value in a column if a value repeats in another column

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

    If the above doesn't return the expected results then I suggest manually populating column F so that we have values with which to compare the results of our proposed formulas/code.
    We may also need detailed explanations of values that are not obvious.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,180

    Re: Reduce subtract a value in a column if a value repeats in another column

    For these type of calculations you start with an "Opening Balance" for each product, then add "Quantities Received" and subtract "Quantities Sold".

    This data is (should be) the "On Hand" quantity.

    Your formatting is (to me) confusing.

+ 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. Grouping column data based on another column without repeats
    By jack.elvy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-28-2021, 06:44 AM
  2. Replies: 1
    Last Post: 12-28-2015, 08:43 AM
  3. VBA code to Subtract values in Column F with Column E if found non-blank
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 04:34 AM
  4. Replies: 6
    Last Post: 12-09-2012, 09:00 PM
  5. Populate column with values from another column - no repeats, and no empties
    By badaboom55 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-23-2010, 09:14 PM
  6. Transpose 2nd column based on repeats in 1st column
    By GregJ in forum Excel General
    Replies: 4
    Last Post: 03-19-2009, 04:29 AM
  7. Replies: 3
    Last Post: 07-04-2008, 07:42 PM

Tags for this Thread

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