I'm revisiting my file and wondered if it's possible to tweak and to apply a minimum and maximum date. Basically, this is my data
[TABLE="width: 500"]
<tbody>[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]Accent[/TD]
[TD]01/01/94[/TD]
[TD]31/12/99[/TD]
[/TR]
[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]i30[/TD]
[TD]01/01/98[/TD]
[TD]31/12/16[/TD]
[/TR]
[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]i40[/TD]
[TD]01/01/99[/TD]
[TD]31/12/17[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Hyundai[/TD]
[TD]Accent[/TD]
[TD]01/01/94[/TD]
[TD]31/12/99[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Subaru[/TD]
[TD]Impreza[/TD]
[TD]01/01/93[/TD]
[TD]31/12/98[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Toyota[/TD]
[TD]Celica[/TD]
[TD]01/01/95[/TD]
[TD]31/12/01[/TD]
[/TR]
[TR]
[TD]PARTNO3[/TD]
[TD]Toyota[/TD]
[TD]Celica[/TD]
[TD]01/08/94[/TD]
[TD]31/05/02[/TD]
[/TR]
[TR]
[TD]PARTNO3[/TD]
[TD]Toyota[/TD]
[TD]MR2[/TD]
[TD]01/01/91[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My original code which concentrates on Columns A, B and C ensures only one unique part number per line.
But how could I get it to understand the value in Column B to ensure it shows the lowest and highest date? So the output would be as follows:
[TABLE="width: 500"]
<tbody>[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai Accent, i30, i40 01/94>12/17[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Hyundai Accent 01/94>12/99. Subaru Impreza 01/93>12/98[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Toyota Celica 08/94>05/02, MR2 01/91>[/TD]
[/TR]
</tbody>[/TABLE]
Any help would be very much appreciated.
[TABLE="width: 500"]
<tbody>[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]Accent[/TD]
[TD]01/01/94[/TD]
[TD]31/12/99[/TD]
[/TR]
[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]i30[/TD]
[TD]01/01/98[/TD]
[TD]31/12/16[/TD]
[/TR]
[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai[/TD]
[TD]i40[/TD]
[TD]01/01/99[/TD]
[TD]31/12/17[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Hyundai[/TD]
[TD]Accent[/TD]
[TD]01/01/94[/TD]
[TD]31/12/99[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Subaru[/TD]
[TD]Impreza[/TD]
[TD]01/01/93[/TD]
[TD]31/12/98[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Toyota[/TD]
[TD]Celica[/TD]
[TD]01/01/95[/TD]
[TD]31/12/01[/TD]
[/TR]
[TR]
[TD]PARTNO3[/TD]
[TD]Toyota[/TD]
[TD]Celica[/TD]
[TD]01/08/94[/TD]
[TD]31/05/02[/TD]
[/TR]
[TR]
[TD]PARTNO3[/TD]
[TD]Toyota[/TD]
[TD]MR2[/TD]
[TD]01/01/91[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My original code which concentrates on Columns A, B and C ensures only one unique part number per line.
Code:
'Removes second column
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
' Removes Duplicates
Columns("A:C").Select
ActiveSheet.Range("$A$1:$C$1000000").RemoveDuplicates Columns:=Array(1, 3), _
Header:=xlNo
' Removes Brackets
Cells.Replace What:=" (*)", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Dim Cl As Range
Dim Dic As Object
Dim Ky As Variant, K As Variant
Set Dic = CreateObject("scripting.dictionary")
With Sheets("Sheet1")
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
If Not Dic.Exists(Cl.Value) Then Dic.Add Cl.Value, CreateObject("scripting.dictionary")
If Not Dic(Cl.Value).Exists(Cl.Offset(, 1).Value) Then
Dic(Cl.Value).Add (Cl.Offset(, 1).Value), Cl.Offset(, 2).Value
Else
Dic(Cl.Value)(Cl.Offset(, 1).Value) = Dic(Cl.Value)(Cl.Offset(, 1).Value) & ", " & Cl.Offset(, 2).Value
End If
Next Cl
End With
With Sheets("Sheet2")
For Each Ky In Dic.Keys
With .Range("A" & Rows.Count).End(xlUp).Offset(1)
.Value = Ky
For Each K In Dic(Ky)
.Offset(, 1).Value = .Offset(, 1).Value & ". " & K & " " & Dic(Ky)(K)
Next K
.Offset(, 1).Value = Replace(.Offset(, 1).Value, ". ", "", 1, 1)
End With
Next Ky
End With
End Sub
But how could I get it to understand the value in Column B to ensure it shows the lowest and highest date? So the output would be as follows:
[TABLE="width: 500"]
<tbody>[TR]
[TD]PARTNO1[/TD]
[TD]Hyundai Accent, i30, i40 01/94>12/17[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Hyundai Accent 01/94>12/99. Subaru Impreza 01/93>12/98[/TD]
[/TR]
[TR]
[TD]PARTNO2[/TD]
[TD]Toyota Celica 08/94>05/02, MR2 01/91>[/TD]
[/TR]
</tbody>[/TABLE]
Any help would be very much appreciated.