Hello Excel Team
I am looking for VBA code that will remove duplicates by column (A&B) and sum and merge for C after clearing cells for (A&B) and merge duplicate cells.
If there are blank rows in column C, they must be merge with the unique rows in the column (A&B).
below sheets:
Worksheet before
Column A should look for all duplicates in its cells and merge them on a condition that the content of the cells in Column B at the same row level can also be merged.
Column C should also look for all duplicates in its cells, merge and sum them on a condition that Column A and Column B had cells that were merged at the same row level.
After using VBA code
I hope I explained it well, thank you in advance for any help
Best regards
Jacob
I am looking for VBA code that will remove duplicates by column (A&B) and sum and merge for C after clearing cells for (A&B) and merge duplicate cells.
If there are blank rows in column C, they must be merge with the unique rows in the column (A&B).
below sheets:
Worksheet before
Zeszyt1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Day of the week | Name | Meters | ||
2 | 01.07.2021 | TOM | 28800 | ||
3 | 01.07.2021 | JOHN | 60800 | ||
4 | 02.07.2021 | TOM | 38400 | ||
5 | 02.07.2021 | MATT | 16000 | ||
6 | 02.07.2021 | MATT | 27200 | ||
7 | 03.07.2021 | DAMIAN | 62400 | ||
8 | 03.07.2021 | TOM | 60500 | ||
9 | 04.07.2021 | DAMIAN | 16000 | ||
10 | 04.07.2021 | DAMIAN | 43400 | ||
11 | 04.07.2021 | TOM | 62850 | ||
12 | 05.07.2021 | PETER | 68600 | ||
13 | 05.07.2021 | JACOB | 63000 | ||
14 | 06.07.2021 | PETER | 9400 | ||
15 | 06.07.2021 | PETER | 53200 | ||
16 | 06.07.2021 | JACOB | 8400 | ||
17 | 06.07.2021 | JACOB | 13800 | ||
18 | 06.07.2021 | JACOB | 19300 | ||
19 | 07.07.2021 | JOHN | 68400 | ||
20 | 07.07.2021 | PETER | 65600 | ||
21 | 08.07.2021 | PETER | 10700 | ||
22 | 08.07.2021 | JOHN | 14400 | ||
23 | 08.07.2021 | JOHN | 15600 | ||
24 | 08.07.2021 | JOHN | 43400 | ||
25 | 08.07.2021 | PETER | 18200 | ||
26 | 08.07.2021 | PETER | 15400 | ||
27 | 08.07.2021 | PETER | 29600 | ||
28 | 09.07.2021 | TOM | 56800 | ||
29 | 09.07.2021 | JOHN | 6000 | ||
30 | 09.07.2021 | JOHN | 39100 | ||
31 | 09.07.2021 | JOHN | |||
32 | 10.07.2021 | TOM | 25600 | ||
33 | 10.07.2021 | JOHN | 51200 | ||
34 | 11.07.2021 | TOM | 48000 | ||
35 | 12.07.2021 | JACOB | 35200 | ||
36 | 12.07.2021 | JACOB | 10200 | ||
37 | 12.07.2021 | TOM | 31200 | ||
38 | 13.07.2021 | MIKE | 40000 | ||
39 | 13.07.2021 | PETER | 40550 | ||
40 | 14.07.2021 | MIKE | 36400 | ||
41 | 14.07.2021 | PETER | 20100 | ||
42 | 14.07.2021 | PETER | 6000 | ||
43 | 14.07.2021 | PETER | |||
44 | 15.07.2021 | JOHN | 5100 | ||
45 | 15.07.2021 | JOHN | |||
46 | 15.07.2021 | JOHN | 6000 | ||
47 | 15.07.2021 | MIKE | 6000 | ||
48 | 15.07.2021 | MIKE | 22500 | ||
49 | 16.07.2021 | JOHN | 19500 | ||
50 | 16.07.2021 | JOHN | 3000 | ||
51 | 16.07.2021 | JOHN | 4500 | ||
52 | 16.07.2021 | JOHN | 5900 | ||
53 | 16.07.2021 | JOHN | 4000 | ||
54 | 16.07.2021 | JOHN | 4200 | ||
55 | 16.07.2021 | MIKE | 57950 | ||
56 | 17.07.2021 | ROBERT | 40000 | ||
57 | 17.07.2021 | ROBERT | 4200 | ||
58 | 17.07.2021 | JOHN | 67200 | ||
59 | 18.07.2021 | ROBERT | 11150 | ||
60 | 18.07.2021 | ROBERT | 34350 | ||
61 | 18.07.2021 | ROBERT | 3200 | ||
62 | 18.07.2021 | JOHN | 39000 | ||
63 | 19.07.2021 | PETER | 41000 | ||
64 | 19.07.2021 | ROBERT | 51200 | ||
65 | 20.07.2021 | PETER | 12200 | ||
66 | 20.07.2021 | PETER | 36000 | ||
67 | 20.07.2021 | ROBERT | 43300 | ||
68 | 20.07.2021 | ROBERT | 3800 | ||
69 | 21.07.2021 | MIKE | 27600 | ||
70 | 21.07.2021 | MIKE | 1500 | ||
71 | 21.07.2021 | PETER | 27000 | ||
72 | 21.07.2021 | PETER | 31500 | ||
73 | 22.07.2021 | MIKE | 13500 | ||
74 | 22.07.2021 | MIKE | 9000 | ||
75 | 22.07.2021 | MIKE | 2950 | ||
76 | 22.07.2021 | PETER | 2000 | ||
77 | 22.07.2021 | PETER | 35350 | ||
78 | 23.07.2021 | JOHN | 77000 | ||
79 | 23.07.2021 | MIKE | 43100 | ||
80 | 23.07.2021 | MIKE | 6000 | ||
81 | 24.07.2021 | JOHN | 34000 | ||
82 | 24.07.2021 | MIKE | 31300 | ||
83 | 25.07.2021 | PETER | 7350 | ||
84 | 25.07.2021 | PETER | 2700 | ||
85 | 25.07.2021 | PETER | 19600 | ||
86 | 25.07.2021 | JOHN | 67200 | ||
87 | 26.07.2021 | ROBERT | 58200 | ||
88 | 26.07.2021 | MATT | 64400 | ||
89 | 27.07.2021 | PETER | 24050 | ||
90 | 27.07.2021 | PETER | 15100 | ||
91 | 27.07.2021 | ROBERT | 55750 | ||
92 | 28.07.2021 | PETER | 54300 | ||
93 | 28.07.2021 | ROBERT | 26700 | ||
94 | 28.07.2021 | ROBERT | 6000 | ||
95 | 28.07.2021 | ROBERT | 9000 | ||
96 | 29.07.2021 | DAMIAN | 27000 | ||
97 | 29.07.2021 | DAMIAN | 30000 | ||
98 | 29.07.2021 | PETER | 10300 | ||
99 | 29.07.2021 | PETER | 25600 | ||
100 | 30.07.2021 | DAMIAN | 44800 | ||
101 | 30.07.2021 | DAMIAN | 3200 | ||
102 | 30.07.2021 | JACOB | 48000 | ||
103 | 30.07.2021 | JACOB | |||
104 | 31.07.2021 | JOHN | 21000 | ||
105 | 31.07.2021 | JOHN | 19500 | ||
106 | 31.07.2021 | JOHN | 5600 | ||
107 | 31.07.2021 | DAMIAN | 35350 | ||
108 | 31.07.2021 | DAMIAN | 25200 | ||
Arkusz2 |
Column A should look for all duplicates in its cells and merge them on a condition that the content of the cells in Column B at the same row level can also be merged.
Column C should also look for all duplicates in its cells, merge and sum them on a condition that Column A and Column B had cells that were merged at the same row level.
After using VBA code
Zeszyt1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Day of the week | Name | Sum of meters after duplicate cells A and B are connected | ||
2 | 01.07.2021 | TOM | 28800 | ||
3 | 01.07.2021 | JOHN | 60800 | ||
4 | 02.07.2021 | TOM | 38400 | ||
5 | 02.07.2021 | MATT | 43200 | ||
6 | |||||
7 | 03.07.2021 | DAMIAN | 62400 | ||
8 | 03.07.2021 | TOM | 60500 | ||
9 | 04.07.2021 | DAMIAN | 59400 | ||
10 | |||||
11 | 04.07.2021 | TOM | 62850 | ||
12 | 05.07.2021 | PETER | 68600 | ||
13 | 05.07.2021 | JACOB | 63000 | ||
14 | 06.07.2021 | PETER | 62600 | ||
15 | |||||
16 | 06.07.2021 | JACOB | 41500 | ||
17 | |||||
18 | |||||
19 | 07.07.2021 | JOHN | 68400 | ||
20 | 07.07.2021 | PETER | 76300 | ||
21 | |||||
22 | 08.07.2021 | JOHN | 73400 | ||
23 | |||||
24 | |||||
25 | 08.07.2021 | PETER | 63200 | ||
26 | |||||
27 | |||||
28 | 09.07.2021 | TOM | 56800 | ||
29 | 09.07.2021 | JOHN | 45100 | ||
30 | |||||
31 | |||||
32 | 10.07.2021 | TOM | 25600 | ||
33 | 10.07.2021 | JOHN | 51200 | ||
34 | 11.07.2021 | TOM | 48000 | ||
35 | 12.07.2021 | JACOB | 45400 | ||
36 | |||||
37 | 12.07.2021 | TOM | 31200 | ||
38 | 13.07.2021 | MIKE | 40000 | ||
39 | 13.07.2021 | PETER | 40550 | ||
40 | 14.07.2021 | MIKE | 36400 | ||
41 | 14.07.2021 | PETER | 26100 | ||
42 | |||||
43 | |||||
44 | 15.07.2021 | JOHN | 11100 | ||
45 | |||||
46 | |||||
47 | 15.07.2021 | MIKE | 28500 | ||
48 | |||||
49 | 16.07.2021 | JOHN | 41100 | ||
50 | |||||
51 | |||||
52 | |||||
53 | |||||
54 | |||||
55 | 16.07.2021 | MIKE | 57950 | ||
56 | 17.07.2021 | ROBERT | 44200 | ||
57 | |||||
58 | 17.07.2021 | JOHN | 67200 | ||
59 | 18.07.2021 | ROBERT | 48700 | ||
60 | |||||
61 | |||||
62 | 18.07.2021 | JOHN | 39000 | ||
63 | 19.07.2021 | PETER | 41000 | ||
64 | 19.07.2021 | ROBERT | 51200 | ||
65 | 20.07.2021 | PETER | 48200 | ||
66 | |||||
67 | 20.07.2021 | ROBERT | 47100 | ||
68 | |||||
69 | 21.07.2021 | MIKE | 29100 | ||
70 | |||||
71 | 21.07.2021 | PETER | 58500 | ||
72 | |||||
73 | 22.07.2021 | MIKE | 25450 | ||
74 | |||||
75 | |||||
76 | 22.07.2021 | PETER | 37350 | ||
77 | |||||
78 | 23.07.2021 | JOHN | 77000 | ||
79 | 23.07.2021 | MIKE | 49100 | ||
80 | |||||
81 | 24.07.2021 | JOHN | 34000 | ||
82 | 24.07.2021 | MIKE | 31300 | ||
83 | 25.07.2021 | PETER | 29650 | ||
84 | |||||
85 | |||||
86 | 25.07.2021 | JOHN | 67200 | ||
87 | 26.07.2021 | ROBERT | 58200 | ||
88 | 26.07.2021 | MATT | 64400 | ||
89 | 27.07.2021 | PETER | 39150 | ||
90 | |||||
91 | 27.07.2021 | ROBERT | 55750 | ||
92 | 28.07.2021 | PETER | 54300 | ||
93 | 28.07.2021 | ROBERT | 41700 | ||
94 | |||||
95 | |||||
96 | 29.07.2021 | DAMIAN | 57000 | ||
97 | |||||
98 | 29.07.2021 | PETER | 35900 | ||
99 | |||||
100 | 30.07.2021 | DAMIAN | 48000 | ||
101 | |||||
102 | 30.07.2021 | JACOB | 48000 | ||
103 | |||||
104 | 31.07.2021 | JOHN | 46100 | ||
105 | |||||
106 | |||||
107 | 31.07.2021 | DAMIAN | 60550 | ||
108 | |||||
Arkusz3 |
I hope I explained it well, thank you in advance for any help
Best regards
Jacob