hi @ImranBhatti
Here you can find a simple piece of code to do your requirement.
It's using column D as auxiliar
I hope it's helpfull for you
Sub SortComments()
Dim myWs As Worksheet
Dim myRange As Range
Dim LastRow As Long
Dim i As Long
Set myWs = Worksheets("Sheet2")
With myWs
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set myRange = .Range("A1:D" & LastRow)
For i = 1 To LastRow
If .Cells(i, 1).Comment Is Nothing Then
.Cells(i, 4).Value = 1
Else
.Cells(i, 4).Value = 0
End If
Next i
End With
myRange.Select
With myWs.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("A1:A" & LastRow), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange myRange
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With myWs.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("D1:D" & LastRow), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange myRange
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks