Inventory and cost management

Balmer07

New Member
Joined
Feb 14, 2018
Messages
45
Office Version
  1. 365
Hi,

I was hoping someone could help me with an excel problem I have.
I run a business and have a purchase list on one tab with all the products I have purchased, the quantity purchased and cost each time they are purchased. I then have a sales list tab which records the sales price, any fees associated with selling and the quantity sold. The missing part of the piece is to pull through the correct price for a product each time it sells.

For example:
I purchase 10 units of Product A for £10.00 each totalling £100.
I then purchase a further 10 units of Product A for £11.00 each totalling £110.
Total stock value is now £210.00 across 20 units.

I then sell 10 units of Product A and so would like the cost pulled through as £10.00 each
I then sell a further 10 units of Product A and so would then like to pull the cost of £11.00 through as there is none of the £10.00 Product left in stock due to the previous sale.

How do I do this? Currently I just do a vlookup and then manually change when I know the price isn't correct but this is not maintainable and I hope there is a solution within excel.

To add a further level of complexity here can a consideration be made if say 11 units of Product A were purchased, therefore 10 units would have the £10.00 cost while 1 would have the £11.00 cost so totalling £111.00


Hopefully this makes sense and there is reasonable solution? Appreciate the help and let me know if any questions.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you tell us what version of excel you have? The answer varies depending greatly on your version.
And i believe you can update your profile with that information.
 
Upvote 0
I have a subscription to Office 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Ok here is something I came up with, with the little time I had. Maybe it could work for you. But i guess a better solution should be done with VBA.

Ok here it is:

I have one Purchase table like so:
Purchases_Sales.xlsx
ABCD
1Purchases
2DateProductQuantityPrice
301/11/2023A10100,00
401/11/2023B550,00
501/11/2023C220,00
601/12/2023A11110,00
701/12/2023B655,00
801/12/2023C330,00
915/12/2023A4115,00
Purchase


And a Sales table like so:
Purchases_Sales.xlsx
ABCDEF
1Sales
2DateProductProduct purchase dateAvailable Quantity [ Purchase date / Quantity / Price ]QuantityPrice
315/12/2023A01/11/2023 5100
416/12/2023A01/11/2023 4100
517/12/2023A01/12/2023 11110
6  
Sale
Cell Formulas
RangeFormula
D3:D6D3=IF(([@Product]<>"")*([@Quantity]=""), LET( cp,[@Product], d,[@[Product purchase date]], p,Purchase[[Date]:[Quantity]], pp,Purchase[Price], ap,VSTACK(p,HSTACK([Product purchase date],[Product],-1*[Quantity])), fap,IF(d="",FILTER(ap,(CHOOSECOLS(ap,2)=cp)*(CHOOSECOLS(ap,3)<>0)),FILTER(ap,(CHOOSECOLS(ap,2)=cp)*(CHOOSECOLS(ap,1)=d)*(CHOOSECOLS(ap,3)<>0))), ud,UNIQUE(CHOOSECOLS(fap,1)), r,HSTACK(ud,BYROW(ud,LAMBDA(x,SUM(FILTER(CHOOSECOLS(fap,3),CHOOSECOLS(fap,1)=x)))),BYROW(ud,LAMBDA(x,FILTER(pp,(CHOOSECOLS(p,2)=cp)*(CHOOSECOLS(p,1)=x))))), rf,FILTER(r,CHOOSECOLS(r,2)<>0), TEXTJOIN(" "&CHAR(10),,BYROW(rf,LAMBDA(y,"[ "&TEXT(CHOOSECOLS(y,1),"aaaa-mm-dd")&" / "&CHOOSECOLS(y,2)&"u / $"&CHOOSECOLS(y,3)&" ]"))) ),"")
F3:F6F3=IF(([@Product]<>"")*([@[Product purchase date]]<>""), FILTER(Purchase[Price],(Purchase[Product]=[@Product])*(Purchase[Date]=[@[Product purchase date]])),"")


If you add a new row to the sales table and enter the Product then you get the list of available units for this product in "Available quantity". If more than one purchase date/price of this product is available you get all those available like this:
Sales1.png


If you cant see all the options just adjust the text:
Sales2.png


Now if you enter the purchase date of one of the listed products then it will only show the number available for that purchase date:
1703245380820.png


I you enter the quantity then the available text will disappear:
1703245509951.png

If you wanted to sell 5 products for example but you had 1u purchased on 2023-11-01 at 100 and 4u purchased on 2023-12-15, then you need to add to lines to the sales table like so:

1703245667036.png


And you have to enter first the product, then the sales date and last the quantity.

I know this isn't perfect but maybe you can use it or change it to something better.
Anyway for anything more advanced maybe VBA is your answer.

Here is a working copy of my file:

Purchases_Sales.zip

And for the date to show correctly in English i think you have to change where it says "aaaa-mm-dd" to "yyyy-mm-dd" in the formula.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top