+ Reply to Thread
Results 1 to 5 of 5

Vlookup with subtract

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-07-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    372

    Vlookup with subtract

    Excel Legends,

    Column A,B and C contain of Order No, Part No and Qty. I need to workout the stock status of each order based on the raw data Column F and G contains of Part No and Stock.

    Example;

    The following part no A5697KT we have customer order 4 and we had a stock 8 nos, the part no appear the first order then formula return the stock 8, if second time return the same part with different order no then formula return the stock 7.

    Any help would be much appreciated.

    ORDER NO PART NO QTY STOCK PART NO STOCK
    2845 A5697KT 1 8 A5697KT 8
    2845 A7119KT 1 2 A7119KT 2
    2845 A5696KT 1 3 A5696KT 3
    2845 A7117KT 1 4 A7117KT 4
    4891 A5697KT 1 7
    4891 A7119KT 1 1
    4891 A5696KT 1 2
    4891 A7117KT 1 3
    5421 A5697KT 1 6
    5421 A7119KT 1 0
    5421 A5696KT 1 1
    5421 A7117KT 1 2
    6821 A5697KT 1 5
    6821 A7119KT 1 0
    6821 A5696KT 1 0
    6821 A7117KT 1 1
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Vlookup with subtract

    Put this G2 and copied down :

    =IFERROR(INDEX(INDEX(D$1:D$1000,MATCH($G$2,D$1:D$1000,0)):D$1000,AGGREGATE(15,6,(ROW(INDEX(D$1:D$1000,MATCH($G$2,D$1:D$1000,0)):D$1000)-ROW(INDEX(D$1:D$1000,MATCH($G$2,D$1:D$1000,0)))+1)/($F3=INDEX(B$1:B$1000,MATCH($G$2,D$1:D$1000,0)):D$1000),1)),"")
    Attached Files Attached Files
    Last edited by azumi; 10-31-2017 at 09:14 PM.

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Vlookup with subtract

    Hello,

    if the first appearance of a Part number has the starting balance in column D, then you can use an Index/Match (or use Vlookup, if you prefer), to find that first occurrence and get the starting balance. Then use a Sumif to work out how many items were ordered for that part number and subtract that from the starting balance.

    =INDEX(D:D,MATCH(F3,B:B,0))-SUMIF(B:B,F3,C:C)

    It would be a lot cleaner if the starting balance was explicitly stated somewhere in the sheet, instead of inferring it from a formula, though.


    cheers, teylyn

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Vlookup with subtract

    @azumi

    Sorry for off-topic interjection:

    Although there is no official rule regarding this behavior, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

    Thanks again for all your hard work here!
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Vlookup with subtract

    crossposted: https://www.ozgrid.com/forum/forum/h...-with-subtract

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

+ 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] How to create Add/Subtract VBA Code with Vlookup ?
    By toradoya in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2016, 09:42 AM
  2. Vlookup to subtract 2 columns
    By vegacapfx in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-02-2015, 02:38 PM
  3. Need help with VLOOKUP or INDEX/MATCH with Subtract formula
    By drheenas in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-05-2014, 07:14 PM
  4. Replies: 2
    Last Post: 08-13-2013, 09:36 AM
  5. [SOLVED] Subtract Using Countifs & Vlookup
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-02-2012, 11:25 AM
  6. Excel 2007 : vlookup,sum,subtract formula help
    By strokedmaro in forum Excel General
    Replies: 3
    Last Post: 06-22-2010, 12:47 AM
  7. Vlookup and subtract when second occurrence of ID
    By transportplanner in forum Excel General
    Replies: 13
    Last Post: 06-16-2010, 09:23 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