I need to add data to the last column, in this case it would be "H". The macro will be ran on different workbooks where the number of columns can change.
I thought the following would work.
Trying to do this
Thank you as usual, this forum has been amazing.
I thought the following would work.
VBA Code:
Lcol As Long
Lcol = Cells(2, Columns.Count).End(xlToLeft).Column
Dim rng As Range
rng = Range("A2")
rng.Offset(0, Lcol).Select
Copy of Area 84 IND Sept-October.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | |||
2 | 600336A3 | 600336PL | 600336SSIFU | 600336SSIVD | 600336VIQS | 601036F | |||
3 | 8 | 5 | 7 | 3 | 0 | 6 | |||
4 | 1 | 1 | 0 | 1 | 0 | 0 | |||
5 | 2 | 2 | 0 | 1 | 0 | 0 | |||
6 | 4 | 2 | 0 | 0 | 0 | 0 | |||
7 | 1 | 2 | 0 | 1 | 0 | 1 | |||
8 | 1 | 3 | 0 | 0 | 0 | 0 | |||
9 | 1 | 0 | 0 | 1 | 1 | 1 | |||
10 | 0 | 4 | 3 | 1 | 1 | 2 | |||
11 | 0 | 2 | 0 | 0 | 0 | 0 | |||
12 | 0 | 0 | 6 | 0 | 0 | 1 | |||
13 | 0 | 0 | 1 | 0 | 2 | 1 | |||
14 | 0 | 0 | 0 | 1 | 0 | 1 | |||
15 | 0 | 0 | 0 | 2 | 0 | 0 | |||
report |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B3:G15 | B3 | =COUNTIFS(data!$H:$H,$A3,data!$A:$A,B$2) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
data!_FilterDatabase | =data!$A$3:$AI$3 | B3:G15 |
Trying to do this
Copy of Area 84 IND Sept-October.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | |||
1 | |||||||||
2 | 600336A3 | 600336PL | 600336SSIFU | 600336SSIVD | 600336VIQS | 601036F | Total | ||
3 | 8 | 5 | 7 | 3 | 0 | 6 | 29 | ||
4 | 1 | 1 | 0 | 1 | 0 | 0 | 3 | ||
5 | 2 | 2 | 0 | 1 | 0 | 0 | 5 | ||
6 | 4 | 2 | 0 | 0 | 0 | 0 | 6 | ||
7 | 1 | 2 | 0 | 1 | 0 | 1 | 5 | ||
8 | 1 | 3 | 0 | 0 | 0 | 0 | 4 | ||
9 | 1 | 0 | 0 | 1 | 1 | 1 | 4 | ||
10 | 0 | 4 | 3 | 1 | 1 | 2 | 11 | ||
11 | 0 | 2 | 0 | 0 | 0 | 0 | 2 | ||
12 | 0 | 0 | 6 | 0 | 0 | 1 | 7 | ||
13 | 0 | 0 | 1 | 0 | 2 | 1 | 4 | ||
14 | 0 | 0 | 0 | 1 | 0 | 1 | 2 | ||
15 | 0 | 0 | 0 | 2 | 0 | 0 | 2 | ||
report |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B3:G15 | B3 | =COUNTIFS(data!$H:$H,$A3,data!$A:$A,B$2) |
H3:H15 | H3 | =SUM(B3:G3) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
data!_FilterDatabase | =data!$A$3:$AI$3 | B3:G15 |
Thank you as usual, this forum has been amazing.