Hi,
I have a table of data showing when quantities of stock have been received (columns C-N) and the total stock remaining of each item. Unfortunately some of the items have multiple lines due to different vendors.
What I need is a formula (or VBA if not possible with a formula) that can take give the total stock for each item taking into account the possible multiple lines.
So in the example attached, most have only one line so not a problem but one item has two lines and the formula would need to produce the results in column P, where it finds the latest stock receipt and then sums back until the total is reached.
Item aaaa vendor a would be 698+1804+8+(3018-698-1804-8-187) = 2831
item aaaa vendor g would be 187
in the main file, not the example attached, there are a few thousand lines and potentially up to 3 occurrences per item
Really struggling with how to get the results required so will be grateful for any assistance!
[TABLE="width: 836"]
<tbody>[TR]
[TD="width: 70, bgcolor: transparent"][/TD]
[TD="width: 51, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Nov-16
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Dec-16
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jan-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Feb-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Mar-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Apr-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]May-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jun-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jul-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Aug-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Sep-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Oct-17
[/TD]
[TD="width: 141, bgcolor: transparent"][/TD]
[TD="width: 116, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]Item Class
[/TD]
[TD="class: xl63, bgcolor: transparent"]vendor
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Oct Stock Qty by item
[/TD]
[TD="class: xl63, bgcolor: transparent"]Oct true stock qty
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: yellow"]aaaaa
[/TD]
[TD="class: xl65, bgcolor: yellow"]a
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3313
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]8
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]1804
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]698
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3018
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]2831
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]bbbb
[/TD]
[TD="bgcolor: transparent"]b
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]1
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]1
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]ccccc
[/TD]
[TD="bgcolor: transparent"]c
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]84
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]84
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]ddddd
[/TD]
[TD="bgcolor: transparent"]d
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]eeeee
[/TD]
[TD="bgcolor: transparent"]e
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]206
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]206
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]fffff
[/TD]
[TD="bgcolor: transparent"]f
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]188
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]39
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]39
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: yellow"]aaaaa
[/TD]
[TD="class: xl65, bgcolor: yellow"]g
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]263
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]187
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3018
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]187
[/TD]
[/TR]
</tbody>[/TABLE]
I have a table of data showing when quantities of stock have been received (columns C-N) and the total stock remaining of each item. Unfortunately some of the items have multiple lines due to different vendors.
What I need is a formula (or VBA if not possible with a formula) that can take give the total stock for each item taking into account the possible multiple lines.
So in the example attached, most have only one line so not a problem but one item has two lines and the formula would need to produce the results in column P, where it finds the latest stock receipt and then sums back until the total is reached.
Item aaaa vendor a would be 698+1804+8+(3018-698-1804-8-187) = 2831
item aaaa vendor g would be 187
in the main file, not the example attached, there are a few thousand lines and potentially up to 3 occurrences per item
Really struggling with how to get the results required so will be grateful for any assistance!
[TABLE="width: 836"]
<tbody>[TR]
[TD="width: 70, bgcolor: transparent"][/TD]
[TD="width: 51, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Nov-16
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Dec-16
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jan-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Feb-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Mar-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Apr-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]May-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jun-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Jul-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Aug-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Sep-17
[/TD]
[TD="class: xl64, width: 61, bgcolor: transparent, align: right"]Oct-17
[/TD]
[TD="width: 141, bgcolor: transparent"][/TD]
[TD="width: 116, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]Item Class
[/TD]
[TD="class: xl63, bgcolor: transparent"]vendor
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Quantity
[/TD]
[TD="class: xl63, bgcolor: transparent"]Oct Stock Qty by item
[/TD]
[TD="class: xl63, bgcolor: transparent"]Oct true stock qty
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: yellow"]aaaaa
[/TD]
[TD="class: xl65, bgcolor: yellow"]a
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3313
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]8
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]1804
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]698
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3018
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]2831
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]bbbb
[/TD]
[TD="bgcolor: transparent"]b
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]1
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]1
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]ccccc
[/TD]
[TD="bgcolor: transparent"]c
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]84
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]84
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]ddddd
[/TD]
[TD="bgcolor: transparent"]d
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]eeeee
[/TD]
[TD="bgcolor: transparent"]e
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]200
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]206
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]206
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]fffff
[/TD]
[TD="bgcolor: transparent"]f
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]188
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]0
[/TD]
[TD="bgcolor: transparent, align: right"]39
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]39
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: yellow"]aaaaa
[/TD]
[TD="class: xl65, bgcolor: yellow"]g
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]263
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]187
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]0
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]3018
[/TD]
[TD="class: xl65, bgcolor: yellow, align: right"]187
[/TD]
[/TR]
</tbody>[/TABLE]