Combining Duplicate Data with Criteria

sakrams

Board Regular
Joined
Sep 28, 2009
Messages
59
Office Version
  1. 2016
Platform
  1. Windows
Hello All,

Wondering if the gurus help me with a formula which would achieve the following looking at the table below. I have more than 1570 records that needs to be fixed.

I have duplicate Names in Column A. Column B and Column C has different dates. I want to combine them all looking at the Name but only keep the Oldest Date from Start Date and the Newest Date from Finish Date.

Original Data
Name
Start Date

<tbody>
</tbody>
Finish Date

<tbody>
</tbody>
S-301

<tbody>
</tbody>
4-Mar-18

<tbody>
</tbody>
4-Mar-18

<tbody>
</tbody>
S-301

<tbody>
</tbody>
6-Mar-18

<tbody>
</tbody>
8-Mar-18

<tbody>
</tbody>
S-301

<tbody>
</tbody>
7-Mar-18

<tbody>
</tbody>
8-Mar-18

<tbody>
</tbody>
S-301

<tbody>
</tbody>
4-Mar-18

<tbody>
</tbody>
9-Mar-18

<tbody>
</tbody>
V-351
6-Mar-18

<tbody>
</tbody>
7-Mar-18

<tbody>
</tbody>
V-351
7-Mar-18

<tbody>
</tbody>
9-Mar-18

<tbody>
</tbody>
V-351
9-Mar-18

<tbody>
</tbody>
11-Mar-18

<tbody>
</tbody>

<tbody>
</tbody>

Result
Name

<tbody>
</tbody>
Start Date

<tbody>
</tbody>
Finish Date

<tbody>
</tbody>
S-301

<tbody>
</tbody>
4-Mar-18

<tbody>
</tbody>
9-Mar-18

<tbody>
</tbody>
V-351

<tbody>
</tbody>
6-Mar-18

<tbody>
</tbody>
11-Mar-18

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Give this a try:

Code:
Public Sub ConsolidateRows()

Dim lastRow As Long
Dim thisRow As Long

lastRow = Cells(Rows.Count, "A").End(xlUp).Row
thisRow = 3
Do While thisRow <= lastRow
    If Cells(thisRow, "A").Value = Cells(thisRow - 1, "A").Value Then
        If Cells(thisRow, "B").Value < Cells(thisRow - 1, "B").Value Then Cells(thisRow - 1, "B").Value = Cells(thisRow, "B").Value
        If Cells(thisRow, "C").Value > Cells(thisRow - 1, "C").Value Then Cells(thisRow - 1, "C").Value = Cells(thisRow, "C").Value
        Cells(thisRow, "A").EntireRow.Delete
        lastRow = lastRow - 1
    Else
        thisRow = thisRow + 1
    End If
Loop

End Sub

WBD
 
Upvote 0
This is amazing Wideboydixon. It worked magic. Thanks a million for all your help.

Give this a try:

Code:
Public Sub ConsolidateRows()

Dim lastRow As Long
Dim thisRow As Long

lastRow = Cells(Rows.Count, "A").End(xlUp).Row
thisRow = 3
Do While thisRow <= lastRow
    If Cells(thisRow, "A").Value = Cells(thisRow - 1, "A").Value Then
        If Cells(thisRow, "B").Value < Cells(thisRow - 1, "B").Value Then Cells(thisRow - 1, "B").Value = Cells(thisRow, "B").Value
        If Cells(thisRow, "C").Value > Cells(thisRow - 1, "C").Value Then Cells(thisRow - 1, "C").Value = Cells(thisRow, "C").Value
        Cells(thisRow, "A").EntireRow.Delete
        lastRow = lastRow - 1
    Else
        thisRow = thisRow + 1
    End If
Loop

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top