Sorting Apples Questions - Using Macros

lotien15

New Member
Joined
Apr 5, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,

Im trying to see if its possible to build a macro with the scenario mentioned below:

We have 3 people (Person A, B, and C). All have different set of apples that are each uniquely barcoded that need to be evenly distributed into 6 baskets. When it comes to uneven numbers divisible by 6, they need to be added back into one of the other baskets (in others words, would restart the count OR basket 1 & 2 would get two apples from Person B); can't have part of an apple.

Person A = 6 Apples
Person B = 8 Apples
Person C = 24 Apples

The goal would be to filter at the column for basket '1' and I would get all of the listed assigned apples from each person.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Upvote 0
Map2 (version 1).xlsb
ABCDEFGHIJKLM
1countRound 6basket123450remaining
2a66a123456empty
3b86b1234567,8
4c2424c1,7,13,192,8,14,203,9,15,214,10,16,225,11,17,236,12,18,24empty
Blad1
Cell Formulas
RangeFormula
E2:E4E2=+A2
F2:K4F2=TEXTJOIN(",",1,FILTER(SEQUENCE($C2),MOD(SEQUENCE($C2),6)=F$1))
C2:C4C2=FLOOR.MATH(B2,6)
M2:M4M2=IFERROR(TEXTJOIN(",",1,FILTER(SEQUENCE(B2),SEQUENCE(B2)>C2)),"empty")
For Person B, you are still left with apple 7 and 8. Is there a way to distribute apple 7 into basket 1 and apple 8 into basket 2? Basically, to continue the distribution till it runs out of apples per person; then continues for distribution with the next person starting with basket 1 and so forth.
 
Upvote 0
Just change the $C2 in the formula to $B2 & then drag down & across.
Excel Formula:
=TEXTJOIN(",",1,FILTER(SEQUENCE($B2),MOD(SEQUENCE($B2),6)=F$1))
 
Upvote 0
1649251630321.png

Same questions but different format. How would I continuously number the apples (rows) but restart the count with each new type of apple like so?
 
Upvote 0
As this is a totally different question, you need to start a new thread.

Did the change I suggested work for you?
 
Upvote 0
Yes it did. Thank you!

I thought that the updated situation was a similar idea in principle but shows you how little I knowo_O -- Will post a new thread for it.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

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