Hi, i need a condition in the below code to only proceed to sort if there is data from row 6 onwards else exit sub
Code:
Sub Test()
Dim lDstRowNum As Long
With Sheets(1)
lDstRowNum = .Cells(.Rows.Count, "A").End(xlUp).Row
If lDstRowNum > 5 Then
With .Range("P6:P" & lDstRowNum)
.Formula = "=MATCH(A6,rngSecSort,0)"
End With
.Range(gGroupHeader).CurrentRegion.Sort Key1:=.Range("P6"), Order1:=xlAscending, _
Key2:=.Range("E6"), Order2:=xlAscending, Key3:=.Range("G6"), Order3:=xlDescending, Header:=xlGuess, _
ordercustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End If
With .Range("P6:P" & lDstRowNum)
.ClearContents
End With
End With
End Sub