+ Reply to Thread
Results 1 to 5 of 5

Formula to calc cost based on previous

  1. #1
    Registered User
    Join Date
    11-02-2017
    Location
    LA
    MS-Off Ver
    2010
    Posts
    8

    Formula to calc cost based on previous

    I have this excel sheet and having trouble with the "Previous Cost" column formula in red.

    The yellow is user entered and the blue is formulated.

    If there is a way to get rid of columns H-L that would be fine too. I really just want the Gain/Loss from sale based on each item as it is bought and sold at different times.. I can give more info if needed.. Hoping someone can help with this like the last time....

    Thanks a lot for the other help.
    Attached Files Attached Files
    Last edited by tdugas2; 10-03-2018 at 06:49 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: CHALLENGE #2 - Thanks for #1

    Hello tdugas2 & Welcome to the Forum,

    Administrative Note:
    • We would love to continue to help you with your query, but first, before we can proceed…
    • Please see Forum Rule #1 about proper thread titles and adjust accordingly...
    HTH
    Regards, Jeff

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,736

    Re: Formula to calc cost based on previous

    I see that you have changed your title.

    You can use this array* formula in cell I2:

    =IF(B2="Buy",0,INDEX(E$1:E1,MAX(IF((C$1:C1=C2)*(B$1:B1="Buy"),ROW($1:1))))*D2)

    *Note that an array formula needs to be committed using the key combination of Ctrl-Shift-Enter (CSE), rather than the usual Enter.

    Then you can copy down using your usual method(s).

    It looks like you had the wrong value in cell I5, as you are selling 75 with a unit price of 2.86.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    11-02-2017
    Location
    LA
    MS-Off Ver
    2010
    Posts
    8

    Re: Formula to calc cost based on previous

    Am I doing something wrong...for I5 with the formula I get 214.5. which should be 286.00 since that was my previous. Also if I buy multiple times before selling it gets inputted as 0?

    Is there a way to get rid of all of it besides the gain/loss and have that formula do all the work?

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,736

    Re: Formula to calc cost based on previous

    286.0 was the total cost of buying 100 units, i.e. unit cost of 2.86. If you sell only 75 of them, then the original cost of that number is 75 * 2.86. You subsequently sell 25 units, so the original cost of those would be 25 * 2.86. If you take the first sale as 286.0 and add on to it the cost of 25 sales, then the total cost will be higher as you are basically counting part of the batch of 100 twice.

    I could only work with the data that you supplied, which should be representative of the real file. If it is substantially different, then you should submit another file. I think it will be difficult, though, to match up with many previous "buys", as they may be at different rates.

    Hope this helps.

    Pete

+ 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. Here's a challenge:
    By RussellNonBrand in forum Excel General
    Replies: 2
    Last Post: 07-26-2011, 11:33 AM
  2. I Challenge You!
    By natepen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-29-2007, 11:39 PM
  3. Who wants a challenge?
    By Aussie_Striker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2006, 09:05 AM
  4. Who wants a challenge?
    By Aussie_Striker in forum Excel General
    Replies: 2
    Last Post: 10-11-2006, 07:53 AM
  5. A Challenge
    By jimbob in forum Excel General
    Replies: 17
    Last Post: 04-01-2006, 05:37 PM
  6. A Challenge
    By mjones in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2005, 04:54 AM
  7. [SOLVED] Challenge to pro's
    By Gee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2005, 07: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