[COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]
[COLOR=darkblue]Sub[/COLOR] KeepLastEntryAndMaxVals()
[COLOR=darkblue]Dim[/COLOR] varSortedData [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR]
[COLOR=darkblue]Dim[/COLOR] varUniqueVals [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR]
[COLOR=darkblue]Dim[/COLOR] LastRow [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
Application.ScreenUpdating = [COLOR=darkblue]False[/COLOR]
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
[COLOR=darkblue]If[/COLOR] LastRow = 1 [COLOR=darkblue]Then[/COLOR]
MsgBox "No data found.", vbInformation
[COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
[COLOR=darkblue]With[/COLOR] Range("C1:V" & LastRow)
.Sort _
key1:=.Cells(1), order1:=xlAscending, _
key2:=.Cells(1, 5), order2:=xlDescending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTop[COLOR=darkblue]To[/COLOR]Bottom
varSortedData = .Offset(1, 0).Resize(.Rows.Count - 1).Value
varUniqueVals = GetUniqueAndMaxVals(varSortedData)
.Offset(1, 0).ClearContents
.Offset(1, 0).Resize(UBound(varUniqueVals, 1), [COLOR=darkblue]UBound[/COLOR](varUniqueVals, 2)).Value = varUniqueVals
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
Application.ScreenUpdating = [COLOR=darkblue]True[/COLOR]
MsgBox "Completed...", vbInformation
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Function[/COLOR] GetUniqueAndMaxVals([COLOR=darkblue]ByVal[/COLOR] varData [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR])
[COLOR=darkblue]Dim[/COLOR] objDic [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
[COLOR=darkblue]Dim[/COLOR] arrUniqueVals() [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR]
[COLOR=darkblue]Dim[/COLOR] UnqIndx [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
[COLOR=darkblue]Dim[/COLOR] i [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
[COLOR=darkblue]Dim[/COLOR] j [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
[COLOR=darkblue]Set[/COLOR] objDic = CreateObject("Scripting.Dictionary")
objDic.CompareMode = 1 [COLOR=green]'vbTextCompare[/COLOR]
[COLOR=darkblue]ReDim[/COLOR] arrUniqueVals(1 [COLOR=darkblue]To[/COLOR] [COLOR=darkblue]UBound[/COLOR](varData, 1), 1 [COLOR=darkblue]To[/COLOR] [COLOR=darkblue]UBound[/COLOR](varData, 2))
UnqIndx = 0
[COLOR=darkblue]For[/COLOR] i = 1 [COLOR=darkblue]To[/COLOR] [COLOR=darkblue]UBound[/COLOR](varData, 1)
[COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] objDic.Exists(varData(i, 1)) [COLOR=darkblue]Then[/COLOR]
UnqIndx = UnqIndx + 1
[COLOR=darkblue]For[/COLOR] j = 1 [COLOR=darkblue]To[/COLOR] [COLOR=darkblue]UBound[/COLOR](varData, 2)
arrUniqueVals(UnqIndx, j) = varData(i, j)
[COLOR=darkblue]Next[/COLOR] j
objDic.Add varData(i, 1), UnqIndx
[COLOR=darkblue]Else[/COLOR]
[COLOR=darkblue]For[/COLOR] j = 8 To UBound(varData, 2)
[COLOR=darkblue]If[/COLOR] Application.IsNumber(varData(i, j)) [COLOR=darkblue]Then[/COLOR]
arrUniqueVals(objDic.Item(varData(i, 1)), j) = _
Application.Max(varData(i, j), arrUniqueVals(objDic.Item(varData(i, 1)), j))
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
[COLOR=darkblue]Next[/COLOR] j
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
[COLOR=darkblue]Next[/COLOR] i
GetUniqueAndMaxVals = arrUniqueVals
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Function[/COLOR]