ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Merging data in multiple rows where the first cell has duplicate d (https://www.excelbanter.com/excel-discussion-misc-queries/146066-merging-data-multiple-rows-where-first-cell-has-duplicate-d.html)

Big Red

Merging data in multiple rows where the first cell has duplicate d
 
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!

JE McGimpsey

Merging data in multiple rows where the first cell has duplicate d
 
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).

In article ,
Big Red <Big wrote:

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!


Big Red[_2_]

Merging data in multiple rows where the first cell has duplica
 
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.

"JE McGimpsey" wrote:

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).

In article ,
Big Red <Big wrote:

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!



Roger Govier

Merging data in multiple rows where the first cell has duplica
 
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.

--
Regards

Roger Govier


"Big Red" wrote in message
...
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.

"JE McGimpsey" wrote:

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).

In article ,
Big Red <Big wrote:

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!






All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com