Hi
i have 3 columns as per attached sample file
id like to be able to
1: Sort by col A
2: combine col B to get a total for duplicate in Col A
3: combine col c to get a total for duplicate in Col A
so as per attached file the outcome would be
Col A Col B Col C
John 111 444
Paul 222 666
below is a macro to just sort and combine values in col B bases on col A - this works perfectly - id like to just add on col 3, and also be able to add on more cols as per my need
Sub SortAndMerge()
'Sort first
'NOTE: Change this select if you wish the sort to be more precise
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'And then merge
Range("A1").Select
'Keep going until we run out of entires in the first column
Do While ActiveCell.Value <> 0
'Loop while the row below matches
Do While ActiveCell.Offset(1, 0).Value = ActiveCell.Value
'The value on this row += the value on the next row
'NOTE: Changing the 1 in the second places on *all three* of these
' offsets will change the row being merged (A+1=B, A+2=C, etc)
ActiveCell.Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value _
+ ActiveCell.Offset(1, 1).Value
'Delete the duplicate row
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp
'Reselect the top row for this group
ActiveCell.Offset(-1, 0).Select
Loop
'Step to next row
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Your help would be really appreciated!!!!!!
Thanks
MESH
Bookmarks