Consulting

Results 1 to 3 of 3

Thread: Public procedure to sort similar rows

  1. #1

    Public procedure to sort similar rows

    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
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    That's awesome and great. Thanks a lot for wonderful help Mr. mdmackillop
    You are awesome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •