Hello,
I have a series of buy and sell transactions, and I would like a macro that assigns the sales to specific buy "lots" based on LIFO (last-in, first-out), and also shows the remaining lots that were not sold. Ideally, the prices would be there too (you bought for $5 and sold for $4, showing a -$1 for that purchase).
For instance, on 6/1 you buy 200 shares, and 6/4 you buy 50 shares, and 6/6 you sell 100 shares.
The macro would split out the 6/6 sales on two lines, one showing 50 shares attributed to the 6/4 buy lot and 50 shares attributed to the 6/1 buy lot, and showing the remaining balance of 150 shares purchased on 6/1.
I've attached the series for representation. Some lots are purchased on the same day, so unfortunately the day isn't a unique identifier, but just assume they are in chronological order (the first was a buy at 10am, the second buy at 2pm, etc.).LIFO.xlsx
Any help would be greatly appreciated!!!
Thanks!
Bookmarks