PDA

View Full Version : [SOLVED] Public procedure to sort similar rows



YasserKhalil
03-24-2017, 11:42 AM
Hello everyone
I need to create public procedure to sort similar rows ...
For example: range("A3:G10") which I want to sort the same colors (the same numbers in columns B:G) so as to be like the output I attached in A15
* A8:G8 is cut and put after A3:G3 and the other rows are the same as they are identical


Thanks advanced for help


I have posted the same request at this link :
http://www.eileenslounge.com/viewtopic.php?f=30&t=26364

mdmackillop
03-24-2017, 01:10 PM
This assumes your actual layout is consistent with your example.

Sub test()
Dim c As Range
Dim i As Long, j As Long, Col As Long
Dim x As String, y as String

Application.ScreenUpdating = False
For Col = 1 To 15 Step 7
Set c = Cells(1, Col).End(xlDown)
Set c = Range(c, c.End(xlDown)).Resize(, 7)
For i = 1 To c.Rows.Count
x = Application.Text(Application.Sum(Range(c(i, 3), c(i, 7))), "000")
y = ""
For j = 3 To 7
y = y & c(i, j)
Next j
c(i, 2) = x & "-" & y
Next i
c.Sort c.Columns(2), xlDescending
c.Columns(2).ClearContents
Next Col
Application.ScreenUpdating = True
End Sub

YasserKhalil
03-24-2017, 01:42 PM
That's awesome and great. Thanks a lot for wonderful help Mr. mdmackillop
You are awesome