Private Sub cmdSort_Click()
Dim r As Range
Dim s As Range
Dim sign As Range
Dim lastrow As Integer
Dim catcount As Double
Dim catcount2 As Double
lastrow = Range("E3").End(xlDown).Row
catcount = lastrow
Set r = Range("G3")
Set s = Range("H3")
Set sign = Range("A3")
Set subsign = Range("B3")
While r.Row <= lastrow
If sign.Value <> "" Then
s.Formula = catcount + 0.1
r.Formula = r.Offset(0, -2).text
catcount2 = catcount
catcount = catcount - 1
Else 'populate cell with value in cell above
r.Formula = r.Offset(-1, 0).text
s.Formula = catcount2
End If
'drop down one row
Set s = s.Offset(1, 0)
Set r = r.Offset(1, 0)
Set sign = sign.Offset(1, 0)
Wend
Call FourKeySort
End Sub
Sub FourKeySort()
SortAll "H3"
SortAll "G3"
SortAll "J3"
SortAll "I3"
SortAll "E3"
End Sub
Sub SortAll(x As String)
Range(x).Sort _
Key1:=Range(x), _
Order1:=xlDescending, _
Header:=xlNo
End Sub
testsort.xlsx
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.