PDA

View Full Version : [SOLVED:] Macro to find duplicates in a column and add the cell contents together



roxnoxsox
11-09-2015, 07:57 AM
Sorry, I've been trying to write this myself for 2 hours now and I'm just getting really lost, is anyone able to help at all?

This is a sample of my data:


S000001

Name1

251298.17



S000002

Name2

61845.00



S000003

Name3

3928.02



S000001

Name1

-5234.99



S000004

Name4

220874.76



S000002

Name2

-61845.00



S000005

Name5

49400.00



S000456

Name6

285000.00





I need this macro to be able to do multiple things so it's a little complicated and I understand if it turns into a long process or needs to be 2 separate macros, I'm just getting really confused!

I need this to look for duplicates in column A (so you can see S000001 and S000002 are both there twice). I then need this to add the contents of column C for these duplicates together. So for S000001 - this is showing 251298.17 in C1 and -5234.99 in C4. I want the macro to delete one of these rows (so S000001 is only showing up once on my spreadsheet) and add the two values together so that column C for this will be showing: 246063.18.

However, it gets even more complicated because like for S000002 (which is a duplicate and showing twice in column A) is showing: 61845.00 in C2 and -61845.00 in C6. Therefore the value of C would be 0. So I want this to remove BOTH rows from the spreadsheet.


Is this at all possible...? I can't wrap my head around this. Please let me know if you have any suggestions or starters for me at all! All help is very much appreciated. Thanks!

roxnoxsox
11-09-2015, 08:05 AM
UPDATE: I have found I can do this well enough by macro recording a pivot table which seems to work :)