Hello! I want to automate some changes I have to make to these tables regularly.
Basically, I need to copy down (autofill) the formulas in columns E4, F4 and G4 (same as M4, N4, O4) the number of times (value) wrote in B1 (J1).
For example, if I write 1 in B1, there should only be 1 column. If I write 2, two columns, etc.
The formula in D4 works differently, it is copied according to the number of columns in the table on the left. (Check L4:L14)
I managed to do it using the following code, but I have no idea about the other formulas.
Basically, I need to copy down (autofill) the formulas in columns E4, F4 and G4 (same as M4, N4, O4) the number of times (value) wrote in B1 (J1).
For example, if I write 1 in B1, there should only be 1 column. If I write 2, two columns, etc.
The formula in D4 works differently, it is copied according to the number of columns in the table on the left. (Check L4:L14)
I managed to do it using the following code, but I have no idea about the other formulas.
VBA Code:
Sub test()
Dim lastRow As Long
lastRow = Range("C" & Rows.Count).End(xlUp).Row
Range("D2").AutoFill Destination:=Range("D2:D" & lastRow)
End Sub
Test1.xlsx | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
1 | Number | 1 | Number | 2 | ||||||||||||||
2 | ||||||||||||||||||
3 | Index | Count | Index | Count | ||||||||||||||
4 | 1 | 51095025 | 0.25 | 1 | 1 | CatItem254319 | 4 | 7453239 | 0.21 | 10 | 10 | CatItem21230 | ||||||
5 | 2 | 26978165 | 5 | 6998459 | 0.15 | 12 | 12 | CatItem12987 | ||||||||||
6 | 3 | 13148406 | 6 | 5727455 | 0.07 | |||||||||||||
7 | 7 | 5331643 | 0.87 | |||||||||||||||
8 | 8 | 3821481 | 0.22 | |||||||||||||||
9 | 9 | 2610562 | 0.63 | |||||||||||||||
10 | 10 | 2427388 | 0.01 | |||||||||||||||
11 | 11 | 2268117 | 0.91 | |||||||||||||||
12 | 12 | 2056462 | 0.28 | |||||||||||||||
13 | 13 | 1802451 | 0.19 | |||||||||||||||
14 | 14 | 1045924 | 0.41 | |||||||||||||||
15 | ||||||||||||||||||
Filtered1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D4,L4:L14 | D4 | =RAND() |
E4 | E4 | =INDEX($A$4:$A$6,RANK.EQ(D4,$D$4:$D$6)+COUNTIF($D$4:D4,D4)-1,1) |
F4 | F4 | =SMALL($E$4:$E$6,ROW(A1)) |
G4,O4:O5 | G4 | =VLOOKUP(F4,Database,2) |
M4:M5 | M4 | =INDEX($I$4:$I$14,RANK.EQ(L4,$L$4:$L$14)+COUNTIF($L$4:L4,L4)-1,1) |
N4:N5 | N4 | =SMALL($M$4:$M$14,ROW(A1)) |