Problem:
Table 1 Information to be distributed to Table 2 and 3 based on two different criteria.
Please see the code below for what I'm attempting to do on the attached file.
1 Sub EWO()
2 '
3 ' EWO Macro
4 '
5
6 '
7 Range("C9:E13").Select
8 ‘Index rows and columns as j,I variables.
9 M = COLUMNS = X = (E-(C-1)) = (5-(3-1)) = 3
10 N = ROWS = Y = (13-(9-1))= 5
11
12 ‘For loop around rows and for each in this range assign variables:
13 For j = 1 to N
14 YR = Cell(j,M).Value
15 CO = Cell(j,M+1) .Value
16 MO = Cell(j,M+2) .Value
17
18 ‘Select the range where Table 2 is being set up:
19 Range("H9:L18").Select
20 ‘Index this range to access it based on the value of the previous three variables recently created.
21 COLUMNS2 = TABLE2X = X2 = (L – (H-1)) =
22 ROWS2 = TABLE2Y = Y2 = (18 – (9-1)) =
23 ‘Fill in the vectors above with the information regarding the years (or create a mapping to do the job for you J)
24 ‘Make ActiveCell in Table 2 range equal to the variables recently created:
25 ActiveCell((Y2 = CO),(X2 = YR)).Value = Value + 1
26
27
28 ‘Select the range where Table 3 is being set up:
29 Range("H9:L18").Offset(, 6).Select
30 ‘Again, index this range to access it based on the value of the previous three variables recently created.
31 COLUMNS3 = TABLE3X = X3 = (N – (R-1)) =
32 ROWS3 = TABLE3Y = Y3 = (18 – (9-1)) =
33 ‘Fill in the vectors above with the information regarding the years (or create a mapping to do the job for you J)
34 ‘Make ActiveCell in Table 3 range equal to the variables recently created:
35 ActiveCell((Y3 = CO),(X3 = YR)).Value = Value + MO ‘Add variable MO to previous cell value
36 ‘Repeat the process based on the loop through the rows in the main data
37 Next
38
39 End Sub
Bookmarks