VBA help - remove duplicates and format (sum/average) other columns

EmilyExcel061020

New Member
Joined
Oct 6, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi there, pretty new to VBA and looking for help building out a code for the below problem. Thanks for you help in advance.

I would like to clean up my data, by removing duplicates based on the output of Column A + Column B, duplicate values are anything before the first ?, any information e.g. (?utmtracking) can be ignored/cleaned up by the code first.

The data columns C-F should then be returned as Sum values (in the case of C & E) and Average values (in the case of D & F) of the duplicate data.

Is this possible? Thanks!

Original Data:

Book1
ABCDEF
1Email NameLinkClicks% ClicksPeople% People
2Unique email name 1https://webaddress.com/?utmtracking280.020498280.021277
3Unique email name 1https://webaddress.com/?utmtrackingb300.021962270.020517
4Unique email name 1https://webaddress.com/?utmtrackingc10.00073210.00076
5Unique email name 4https://webaddress.com/linktodocument?utmtrackinga10.00073210.00076
6Unique email name 5https://webaddress.com/linktodocument?utmtrackingb20.00146420.00152
7Unique email name 6https://webaddress.com/linktodocument?utmtrackingc10.00073210.00076
8Unique email name 6https//google.com10.00073210.00076
Sheet2


Desired Output:

Book1
ABCDEF
10Email NameLinkClicks% ClicksPeople% People
11Unique email name 1https://webaddress.com/?utmtracking590.014560.014
12Unique email name 4https://webaddress.com/linktodocument?utmtrackinga10.00073210.00076
13Unique email name 5https://webaddress.com/linktodocument?utmtrackingb20.00146420.00152
14Unique email name 6https://webaddress.com/linktodocument?utmtrackingc10.00073210.00076
15Unique email name 6https//google.com10.00073210.00076
Sheet2
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi there, pretty new to VBA and looking for help building out a code for the below problem. Thanks for you help in advance.

I would like to clean up my data, by removing duplicates based on the output of Column A + Column B, duplicate values are anything before the first ?, any information e.g. (?utmtracking) can be ignored/cleaned up by the code first.

The data columns C-F should then be returned as Sum values (in the case of C & E) and Average values (in the case of D & F) of the duplicate data.

Is this possible? Thanks!

Original Data:

Book1
ABCDEF
1Email NameLinkClicks% ClicksPeople% People
2Unique email name 1https://webaddress.com/?utmtracking280.020498280.021277
3Unique email name 1https://webaddress.com/?utmtrackingb300.021962270.020517
4Unique email name 1https://webaddress.com/?utmtrackingc10.00073210.00076
5Unique email name 4https://webaddress.com/linktodocument?utmtrackinga10.00073210.00076
6Unique email name 5https://webaddress.com/linktodocument?utmtrackingb20.00146420.00152
7Unique email name 6https://webaddress.com/linktodocument?utmtrackingc10.00073210.00076
8Unique email name 6https//google.com10.00073210.00076
Sheet2


Desired Output:

Book1
ABCDEF
10Email NameLinkClicks% ClicksPeople% People
11Unique email name 1https://webaddress.com/?utmtracking590.014560.014
12Unique email name 4https://webaddress.com/linktodocument?utmtrackinga10.00073210.00076
13Unique email name 5https://webaddress.com/linktodocument?utmtrackingb20.00146420.00152
14Unique email name 6https://webaddress.com/linktodocument?utmtrackingc10.00073210.00076
15Unique email name 6https//google.com10.00073210.00076
Sheet2
Edit: this is the desired output
Book1
ABCDEF
17Email NameLinkClicks% ClicksPeople% People
18Unique email name 1https://webaddress.com/590.014560.014
19Unique email name 4https://webaddress.com/linktodocument10.00073210.00076
20Unique email name 5https://webaddress.com/linktodocument20.00146420.00152
21Unique email name 6https://webaddress.com/linktodocument10.00073210.00076
22Unique email name 6https//google.com10.00073210.00076
Sheet2
 
Upvote 0

Forum statistics

Threads
1,214,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

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