View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Advance handling with duplicates

Sub Test()
Dim iLastRow As Long
Dim iLastCol As Long
Dim i As Long, j As Long
Dim rng As Range

Application.ScreenUpdating = False

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
iLastCol = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To iLastRow
If Cells(i, "A").Value = Cells(i + 1, "A").Value Then
For j = 2 To iLastCol
Cells(i + 1, j).Value = Cells(i + 1, j).Value + _
Cells(i, j).Value
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
Next j
End If
Next i

If Not rng Is Nothing Then rng.Delete

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
most of the code and help is on removing duplicates. however, my problem

is
that my duplicates data occur becos my other dept key in data w/o a

standard
format and we can not make changes to the main data sheet except to sort

it
out to other sheet ourself.I will need to combine data from both

duplicates
into one data.

Illustration:

orginal data:
Name Jan Feb March
alan 0 0 1
alan 1 0 0

what i want in the end:
Name Jan Feb March
alan 1 0 1