[Solved] Duplicate number and it value in column EXCEL [closed]


Option Explicit

Sub wqewrty()
    With Worksheets("sheet1").Cells(1, 1).CurrentRegion
        .Cells.Sort Key1:=.Columns(1), Order1:=xlAscending, _
                    Key2:=.Columns(2), Order2:=xlAscending, _
                    Orientation:=xlTopToBottom, Header:=xlNo
        With .Columns(1).Offset(1, 0)
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=$A2=$A1"
            .FormatConditions(1).NumberFormat = ";;;"
        End With
    End With
End Sub

I’ve assumed that you wanted to use column B as a secondary sort key to the primary sort key on column A. If not, remove the second key and order from the .Sort command.

enter image description here

2

solved Duplicate number and it value in column EXCEL [closed]