Insert rows based on sum

Cimpcrro

New Member
Joined
Nov 16, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to build a list by copying in logical order the rows from 3 tables containing:
Existing stock,
Sales orders
Purchase orders

for each item in inventory.

Since there is no other available sorting criteria (no dates) the VBA should get the available inventory, then a number of lines from Sales orders until the sum of above lines <0, then the next Purchase Order Line.
- If there is no stock available, first line should be first PO
- If there is no more PO lines to add the SO lines continue under the value of 0.

Thank you!
 

Attachments

  • Example.JPG
    Example.JPG
    44.9 KB · Views: 14

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
So we need the data, along with destination table.
I am only interested in item no, and qty. We need to get the rows based on calculated value of the rows above it, for each item. It's not necessary to actually have the Sumif column
 
Upvote 0
So we need the data, along with destination table.


Destination Table:

test.xlsx
ABCD
1TypeItem no.QTYSUM
2Stock1111000
3Sales order111-112888
4Sales order111-657231
5Sales order111-22011
6Purchase Order11110001011
7Sales order111-159852
8Sales order111-77874
9Sales order222-543-469
10Stock222800
11Sales order222-203597
12Sales order222-53265
13Purchase Order22210001065
14Sales order222-322743
15Sales order222-499244
16Sales order222-543-299
17Sales order222-323-622
18Sales order222-133-755
19Sales order222-543-1298
Destination table
Cell Formulas
RangeFormula
D3,D11D3=C2+C3
D4:D9,D12:D19D4=D3+C4
Sales Orders:
test.xlsx
ABC
1TypeItem no.QTY
2Sales order111-112
3Sales order111-657
4Sales order111-220
5Sales order111-159
6Sales order111-778
7Sales order222-543
8Sales order222-203
9Sales order222-532
10Sales order222-322
11Sales order222-499
12Sales order222-543
13Sales order222-323
14Sales order222-133
15Sales order222-543
Sales Order


Purchase Orders:

test.xlsx
ABC
1TypeItem no.QTY
2Purchase Order1111000
3Purchase Order2221000
Purchase orders


Inventory:

test.xlsx
ABC
1TypeItem no.QTY
2Stock1111000
3Stock222800
Inventory


Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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