mbotros1,
Welcome to the MrExcel forum.
What version of Excel and Windows are you using?
Are you using a PC or a Mac?
Sample raw data:
Excel 2007
| A | B | C | D | E | F | G |
---|
1 | Name | Week ending | Days off | | | | |
2 | John Smith | 1/31 | 2 | | | | |
3 | John Smith | 2/7 | 1 | | | | |
4 | John Smith | 2/7 | 3 | | | | |
5 | Peter Sun | 1/31 | 1 | | | | |
6 | Peter Sun | 2/7 | 2 | | | | |
7 | Andy Mann | 3/14 | 3 | | | | |
8 | | | | | | | |
<COLGROUP><COL><COL><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
Sheet1
After the macro:
Excel 2007
| A | B | C | D | E | F | G |
---|
1 | Name | Week ending | Days off | | | Name | Totals |
2 | John Smith | 1/31 | 2 | | | John Smith | 6 |
3 | John Smith | 2/7 | 1 | | | Peter Sun | 3 |
4 | John Smith | 2/7 | 3 | | | Andy Mann | 3 |
5 | Peter Sun | 1/31 | 1 | | | | |
6 | Peter Sun | 2/7 | 2 | | | | |
7 | Andy Mann | 3/14 | 3 | | | | |
8 | | | | | | | |
<COLGROUP><COL><COL><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
Sheet1
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
1. Copy the below code
2. Open your NEW workbook
3. Press the keys
ALT +
F11 to open the Visual Basic Editor
4. Press the keys
ALT +
I to activate the Insert menu
5. Press
M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys
ALT +
Q to exit the Editor, and return to Excel
8. To run the macro from Excel press
ALT +
F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Code:
Option Explicit
Sub MergeDupesColA_SumColC()
' hiker95, 03/17/2014, ME764802
Dim a As Variant, o, p, i As Long, d As Object
a = Range("A1:C" & Range("A" & Rows.Count).End(xlUp).Row)
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = 1
For i = 2 To UBound(a, 1)
d(a(i, 1)) = d(a(i, 1)) + a(i, 3)
Next i
Columns("F:G").ClearContents
Cells(1, 6).Resize(, 2).Value = Array("Name", "Totals")
o = Application.Transpose(Array(d.Keys, d.Items))
ReDim p(1 To UBound(o, 1), 1 To 2)
For i = 1 To UBound(o, 1)
p(i, 1) = o(i, 1)
p(i, 2) = o(i, 2)
Next i
Cells(2, 6).Resize(UBound(p, 1), UBound(p, 2)) = p
Columns("F:G").AutoFit
End Sub
You may have to add the
Microsoft Scripting Runtime to the
References - VBA Project.
Press the keys
ALT +
F11 to open the Visual Basic Editor
In the VBA Editor, click on:
Tools
References...
Put a checkmark in the box marked
Microsoft Scripting Runtime
Then click on the
OK button.
And, exit out of the VBA Editor.
Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension
.xlsm
Then run the
MergeDupesColA_SumColC macro.