A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
try this code
data on Sheet1 in columns A, B (in row 1 are headings),
export data in a new Sheet
Sub mySort()
Dim ws As Worksheet, newWS As Worksheet
Dim r As Long
Set ws = Sheets("Sheet1") '<< change name
r = ws.Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
Set newWS = Sheets.Add
ws.Range("A1:B" & r).Copy Destination:=newWS.Range("A1")
For i = 2 To r - 1
If Left(newWS.Cells(i, 1), 1) = Left(newWS.Cells(i + 1, 1), 1) Then
newWS.Cells(i + 1, 2) = ws.Cells(i, 2)
newWS.Cells(i + 1, 2).Interior.ColorIndex = 6
End If
Next
newWS.Range("A2:B" & r).Sort key1:=newWS.Range("B2"), Header:=xlNo
For Each rr In newWS.Range("B2:B" & r)
If rr.Interior.ColorIndex = 6 Then
rr.Value = ""
rr.Interior.ColorIndex = 0
End If
Next
Application.ScreenUpdating = True
End Sub