Sorting data with conditions

stuckhere

New Member
Joined
Jun 26, 2019
Messages
1
Hi,

Appologies if this is long winded but it seemed the easiest way to explain myself.

I need to create a solution to break the following table up into multiple, 2 part sections A&B.

The total quanity of each section must be divisable by 15. Neither section can exceed 45,270 and the sum of the two sections cannot exceed 75,450. The remainder can go in the final section however again cannot exceed 75450


[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl65, width: 64"]A[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]B[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]C[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]D[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]E[/TD]
[TD="class: xl65, width: 64, align: right"]15090[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]F[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]G[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]H[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]I[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]J[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]K[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]L[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]M[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]N[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]O[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]P[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]Q[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]R[/TD]
[TD="class: xl65, width: 64, align: right"]15090[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]S[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]T[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]U[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]V[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]W[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]X[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
</tbody>[/TABLE]

So based on this data it would look as follows:

Section 1- PART A
[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl65, width: 64"]A[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]B[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]C[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]D[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]E[/TD]
[TD="class: xl65, width: 64, align: right"]15090[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]F[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]G[/TD]
[TD="class: xl65, width: 64, align: right"]5030
[/TD]
[/TR]
</tbody>[/TABLE]

Sum of section 1 part A - 45270. Is divisable by 15- OK

SECTION 2 - PART B


<tbody>
[TD="class: xl65"]H[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]

[TD="class: xl65, width: 64"]I[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]

[TD="class: xl65, width: 64"]J[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]

[TD="class: xl65, width: 64"]K[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]

[TD="class: xl65, width: 64"]L[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]

[TD="class: xl65, width: 64"]M[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]

</tbody>

Sum of section 2 part B - 30180. Is divisable by 15 -OK

Sum of Part A & Part B is 75450 - OK

Section 3 - PART A

[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl65, width: 64"]N[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]O[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]P[/TD]
[TD="class: xl65, width: 64, align: right"]10060[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]Q[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]R[/TD]
[TD="class: xl65, width: 64, align: right"]15090[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]S[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]T[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
</tbody>[/TABLE]

Sum of section 3 part A - 45270. Is divisable by 15- OK


Section 3 PART B

[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl65, width: 64"]U[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]V[/TD]
[TD="class: xl65, width: 64, align: right"]2515[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64"]W[/TD]
[TD="class: xl65, width: 64, align: right"]5030[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 64, align: right"][/TD]
[/TR]
</tbody>[/TABLE]
Sum of section 3 part B - 12575 - NOT DIVISABLE by 15 but as the remainder this is ok

Sum of Part A & Part B is 57845 - OK

Any help as to how to achive this is much appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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