Sort Repeating Pattern into Table

AppleSource

New Member
Joined
Jan 10, 2021
Messages
5
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
So, i have odd problem. im sure its reasonably simple but im not sure of the best way to accomplish it. Ive made a simple example to show what i need to do on a small scale.
I would like names to be placed into the columns of IMAGE 1, according to the pattern defined by IMAGE 2
Image 3 is showing an example of one person placed into the table.
Eg: BOB-apple(1/1/21),orange(2/1/21),none(3/1/21),orange(4/1/21),banana(5/1/21),banana(6/1/21)....... Then it repeats
So the end Result will show each day who gets which fruit, (also there are days which someone may get no fruit, cos they arent there.)
I would like to use VBA to "Push data" into the table in IMAGE 1.
Sort Example pic 1.PNG
(IMAGE 1)
SorT Example Pic 2.PNG(IMAGE 2)
Sort Example pic 3.PNG
(IMAGE 3)

Hope This makes sense, if anything needs clarifying lemme know :s
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Assuming IMAGE 2 is on "Sheet2" a formula will do the job

B2 =INDEX(Sheet2!$A$1:$G$1,1,MATCH(B$1,Sheet2!A2:G2)) ....copied down and across
 
Upvote 0
Assuming IMAGE 2 is on "Sheet2" a formula will do the job

B2 =INDEX(Sheet2!$A$1:$G$1,1,MATCH(B$1,Sheet2!A2:G2)) ....copied down and across
Result image.PNG
.... came up with odd results, unless Ive not entered the formula correctly.
Below is the formulas applied to a few different cells.
D2 should equal Mike, B4 Should be John. B2 Is correct tho.
b2,b4,d2.png


the other problem is that the formula wouldn't allow for the pattern to loop i would have to re-enter the formula every 6 rows??
 
Upvote 0
Apologies, I made a mistake

B2 =INDEX(Sheet2!$A$1:$G$1,1,MATCH(B$1,Sheet2!$A2:$G2,0))
:) That fixed it, champion,
How would i make it repeat the pattern without manually re-entering the formula every 6 rows ?
 
Upvote 0
Welcome to the MrExcel board!

It looks like both sheets contain formal Excel tables. If that is so and the table on Sheet1 is called Table1 and the table on Sheet2 is called Table2 then see if this helps.

BTW, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

AppleSource.xlsm
ABCDEFG
1BOBTONYGARYTIMJOHNHARRYMIKE
2APPLEORANGENONEPINEAPPLENONEPEARBANANA
3ORANGEAPPLEBANANANONEPEARNONEPINEAPPLE
4NONEBANANAPEARPINEAPPLEAPPLEORANGENONE
5ORANGEPINEAPPLENONEBANANAPEARNONEAPPLE
6BANANAPEARAPPLENONENONEPINEAPPLEORANGE
7BANANANONEORANGEAPPLEPINEAPPLENONEPEAR
Sheet2


If you put (copy/paste) the B2 formula below into that cell it should spill all the way down the column.
You can then copy (drag) that B2 formula across that first row in the table. They may not immediately spill down but if you go into each of those top row cells and press F2 then Enter they should spill down.

AppleSource.xlsm
ABCDEF
1DatesAPPLEORANGEBANANAPEARPINEAPPLE
21/01/2021BOBTONYMIKEHARRYTIM
32/01/2021TONYBOBGARYJOHNMIKE
43/01/2021JOHNHARRYTONYGARYTIM
54/01/2021MIKEBOBTIMJOHNTONY
65/01/2021GARYMIKEBOBTONYHARRY
76/01/2021TIMGARYBOBMIKEJOHN
87/01/2021BOBTONYMIKEHARRYTIM
98/01/2021TONYBOBGARYJOHNMIKE
109/01/2021JOHNHARRYTONYGARYTIM
1110/01/2021MIKEBOBTIMJOHNTONY
1211/01/2021GARYMIKEBOBTONYHARRY
1312/01/2021TIMGARYBOBMIKEJOHN
1413/01/2021BOBTONYMIKEHARRYTIM
1514/01/2021TONYBOBGARYJOHNMIKE
1615/01/2021JOHNHARRYTONYGARYTIM
1716/01/2021MIKEBOBTIMJOHNTONY
1817/01/2021GARYMIKEBOBTONYHARRY
1918/01/2021TIMGARYBOBMIKEJOHN
2019/01/2021BOBTONYMIKEHARRYTIM
Sheet1
Cell Formulas
RangeFormula
B2:B20B2=INDEX(Table2[#Headers],MATCH(Table1[[#Headers],[APPLE]],INDEX(Table2,MOD(ROW()-ROW(Table1[#Headers])-1,ROWS(Table2))+1,0),0))
C2:C20C2=INDEX(Table2[#Headers],MATCH(Table1[[#Headers],[ORANGE]],INDEX(Table2,MOD(ROW()-ROW(Table1[#Headers])-1,ROWS(Table2))+1,0),0))
D2:D20D2=INDEX(Table2[#Headers],MATCH(Table1[[#Headers],[BANANA]],INDEX(Table2,MOD(ROW()-ROW(Table1[#Headers])-1,ROWS(Table2))+1,0),0))
E2:E20E2=INDEX(Table2[#Headers],MATCH(Table1[[#Headers],[PEAR]],INDEX(Table2,MOD(ROW()-ROW(Table1[#Headers])-1,ROWS(Table2))+1,0),0))
F2:F20F2=INDEX(Table2[#Headers],MATCH(Table1[[#Headers],[PINEAPPLE]],INDEX(Table2,MOD(ROW()-ROW(Table1[#Headers])-1,ROWS(Table2))+1,0),0))
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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