The worksheets have hundreds of rows with account numbers in column A, an account description in column B and totals in column C. I want to copy the rows from all 3 worksheets into a single 4th worksheet but where duplicate account numbers are found, I want there just to be one with the totals aggregated into column C of that row and the extras deleted, like this:
Input from sheets (all the sheets are in one .xls file):
Sheet 1 of workbook
A B C
1 abc-123 Project Costs 1,548.33
2 abc-321 Housing Expenses 250
3 abc-567 Helicopter Rides 11,386.91
Sheet 2 of workbook
A B C
1 abc-123 Project Costs 1,260.95
2 abc-321 Housing Expenses 125
3 abc-567 Helicopter Rides 59,605.48
Sheet 3 of workbook
A B C
1 abc-123 Project Costs 1,785.48
2 abc-321 Housing Expenses 354
3 def-345 Elephant Treats 814,575.31
What I would want the result to be:
A B C
1 abc-123 Project Costs 4,642.28
2 abc-321 Housing Expenses 729
3 abc-567 Helicopter Rides 70,992.39
4 def-345 Elephant Treats 814,575.31
Notice: Some of the account numbers don't ever repeat, but some do.
Best Answer
Here's one way.
Create a new module (VBA editor -> Insert -> Module) and paste the above code into it.
Add a reference to Microsoft Scripting Runtime (VBA editor -> Tools -> References -> Check 'Microsoft Scripting Runtime').
Run it by placing the cursor within the code and pressing F5.
Obviously the sheets will have to be named Sheet1, Sheet2, Sheet3 and Sheet4. It won't paste the column headers into Sheet4 but presumably they are static so you can just set them up yourself beforehand.