Merging data in multiple rows where the first cell has duplicate d

B

Big Red

I need to look at rows in the worksheet and determine if there are duplicates
in column A. If there are, I need to combine the two rows and delete one of
them. In most columns on the row, there are numeric entries. Here is what I
want to happen:

Current:

Dale 2 3 4
Dale 4 2 3
Dale 3 4 2

After Macro:

Dale 9 9 9

There are more than three numeric columns, so I need it to act on the whole
row or be able to define a range for the loop. There is no limit on the rows
where the first cell might be duplicated, although, the data will be sorted
on column A.

Hope someone can help! Thanks!
 
J

JE McGimpsey

Any reason you have to use a macro?

Using a Pivot Table would seem to be a much easier solution (one that
eliminates the need for sorting as well).
 
B

Big Red

JE, thanks for replying! This will be one piece of a much larger macro. There
is a lot of formatting and other automation that I'm doing. I would rather
just have a piece of VBA code that would do the job. If you can help me, I
would sure appreciate it.
 
R

Roger Govier

Hi

One way you could do it easily, if you can accept your data moving to
another sheet, would be to consolidate the data

Sheets("Sheet4").Select
Range("A1").Select
Selection.Consolidate Sources:="[Book2]Sheet1!R1C1:R1000C13",
Function:=xlSum, _
TopRow:=False, LeftColumn:=True, CreateLinks:=False

Set the Workbook and sheet names as appropriate, and make the range
sufficient to cover all of your data.
In this example you would end up with a list on Sheet4 consisting of a
single row for each person summarised in the way you require.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top