Subtracting Quantity Sold twice from Inventory on Hand

JCK101

New Member
Joined
Feb 1, 2012
Messages
32
Office Version
  1. 2019
Platform
  1. Windows
I volunteer for an Athletic Youth Club that needs to keep track of their inventory of basketball and soccer uniforms.

I'm not allowed to upload attachments, so here are the worksheets and headers with problem data.

INVENTORY sheet
Column Headings:

DateProductSizeJersey#QtyHelperSoldOnHand

<tbody>
</tbody>
11/2/2016JerseyAL381Jersey-AL-3801

<tbody>
</tbody>
11/2/2016ShortsAL12Shorts-AL-210

<tbody>
</tbody>
11/3/2016ShortsAL12Shorts-AL-210

<tbody>
</tbody>

The shorts (Shorts) are identified by size only. The quantities can be from 0 to the number of shorts in stock.
The formula in Column(Sold) is: =-SUMIF(Sales!$G$2:$G$1285,F2,Sales!$H$2:$H$1285)
Note:
I use helper columns to identify unique jerseys and soccer sets, by size and jersey number, the quantities are always one (1).

Problem:
Shorts-AL were bought twice a total of 24. Then sold 2 of them, balance should be 22, but using above formula, it is 20, the -2 is deducted from both purchases

SALES sheet
All sales are registered here.
Column Headings:
DateReceipt#NameProductSizeJerseyNoHelperQty

<tbody>
</tbody>
1/19/20172998Erik EstradaShortsALShorts-AL1$5.00$5.00
1/19/20172999Mathew KingstonSocSetYXL46SocSet-YXL-461$10.00$10.00
1/19/201730201Harry InchonJerseyAL8Jersey-AL-81$10.00$10.00
1/19/201730201Harry InchonShortsALShorts-AL1$5.00$5.00

<tbody>
</tbody>

I read in this forum that Access is better for tracking inventory, but could not find an appropriate template that keeps track of inventory by not only product type and size, but also jersey numbers on each uniform. Any help will be much appreciated. Have a great day!
JC
:cool:
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Instead of including sales with purchase I would create its own record since the date matters.
A
B
C
D
E
F
G
H
1
Date
Product
Size
Jersey#
Qty
Helper
sold
OnHand
2
11/2/2016
Jersey
AL
38
1
Jersey-AL-38
1
3
11/2/16
Shorts
AL
12
Shorts-AL
12
4
11/3/16
Shorts
AL
12
Shorts-AL
24
5
11/19/17
Shorts
AL
Shorts-AL
-2
22

<tbody>
</tbody>


Code:
=-SUMIFS(sales!$H$2:$H$5,sales!$G$2:$G$5,F2,sales!$A$2:$A$5,A2)
 
Upvote 0
Thank you Scott for taking the time to help. I plugged in your code and unfortunately it did not work.

The code I have now, works perfectly for sales of Jerseys and SocSet's, but not on generic products that don't have numbers on them also are bought in quantities and multiple times.

Also, the date in this case only, does not matter, it is informational for this operation.

The code I have, is looking up "all" rows with "Shorts-AL" and "subtracting" the qty from the Sales!H:H column corresponding to "Shorts-AL".

What I need to have is a code that will NOT subtract the qty from the Sales!H:H column from each row matching "Shorts-AL" in Inventory!G:G column, but DO subtract from only the first "Short-AL" that has in OnHand column a quantity equal to or more than the quantity sold. And if the quantity sold is "greater" than the quantity OnHand, subtract the balance from the "second" or Nth row matching "Shorts-AL".

Like I previously explained "Shorts-AL" were purchased twice, 12 each time, for a total of 24 so far, and only 2 have been sold, so the total OnHand should be 22, if 6 were sold the OnHand should be 18 and so forth.

Lets see if someone else can come up with a suggestion to make it work the way it should be.
JC
:cool:


Instead of including sales with purchase I would create its own record since the date matters.


Code:
=-SUMIFS(sales!$H$2:$H$5,sales!$G$2:$G$5,F2,sales!$A$2:$A$5,A2)
 
Upvote 0
What did not work? Did you put the formula in G2 and copy down.

You could also just list all your products at the top and then use your sumif formula

ABCDEFGH
1DateProductSizeJersey#QtyHelpersoldOnHand
2Shorts-AL2
311/2/2016JerseyAL381Jersey-AL-381
411/2/16ShortsAL12Shorts-AL10
511/3/16ShortsAL12Shorts-AL22
6

<tbody>
</tbody>


In G2 Do not copy it down. This will always so how many Shorts-AL you have sold and since you did not copy it will not be counted twice but could then be taken out of the on hand calculation.
Code:
[COLOR=#574123] =-SUMIF(Sales!$G$2:$G$1285,F2,Sales!$H$2:$H$1285)[/COLOR]
 
Upvote 0
Thank you Scott for your help.

Your solution cannot be used, I have to copy the formula down "all" rows not just the first row of the Shorts-AL, If I did what you are suggesting, my COGS and in stock values which I intend to implement will not be accurate.

Thank you for your effort.
Cheers.
 
Upvote 0
See if this works.

In G2 and copy down
Code:
=IF(SUMIF(F$1:F1,F2,H$1:H1)>0,0,IF((SUMIF(sales!$G$2:$G$1285,F2,sales!$H$2:$H$1285)-SUMIF(F$1:F1,F2,E1:E$1))<=(E2+SUMIF(F$1:F1,F2,E$1:E1)),-SUMIF(sales!$G$2:$G$1285,F2,sales!$H$2:$H$1285)+SUMIF(F$1:F1,F2,E$1:E1),-E2))
 
Last edited:
Upvote 0
[SOLVED] Re: Subtracting Quantity Sold twice from Inventory on Hand

Great job Scott,

It works perfect as far as I can test it. And works in FIFO method.

My next step is to add the COGS and test it further.

Can you describe what each section of the code is about, so I can understand it better and maybe use it in my COGS portion.

Again thank you for your help
:cool:
 
Upvote 0
Re: [SOLVED] Re: Subtracting Quantity Sold twice from Inventory on Hand

This sums the on hand column with the range from the top to the row above. If his is greater then zero then this row should be 0 since there are still rows above with product on hand.
Code:
=IF(SUMIF(F$1:F1,F2,H$1:H1)>0,0,

The first part is your sumif formula then subtract the qty for all the rows above. This is compared to the total qty up to this row, so on the first shorts row it is 12 on the second on it is 24. This check if the amount sold will go over the Qty. If so it puts in the Qty as the number sold that is the -E2 at the end of the formula, otherwise it calculates the amount sold.
Code:
IF((SUMIF(sales!$G$2:$G$1285,F2,sales!$H$2:$H$1285)-SUMIF(F$1:F1,F2,E1:E$1))<=(E2+SUMIF(F$1:F1,F2,E$1:E1))


This calculates the amount sold by taking your sumif formula giving total sold as a negative number, and adding the total Qty not including this row, since that has already been sold.
Code:
-SUMIF(sales!$G$2:$G$1285,F2,sales!$H$2:$H$1285)+SUMIF(F$1:F1,F2,E$1:E1)
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

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