Results 1 to 2 of 2

MultiLevel Sort till end column

Threaded View

  1. #1
    Registered User
    Join Date
    04-11-2014
    Location
    Australia
    MS-Off Ver
    Excel 2003, 2010, 2013
    Posts
    33

    MultiLevel Sort till end column

    Hi,

    I am having difficulty on the macro to do multilevel sort by color.

    Criteria
    - Sort each column that have highlighted till end column (this can be about 40 columns and 500 rows data)
    - Ignore the column that no highlighted cell
    - Keep the information align when sort across column and row

    Below is the VB that tried to develop but seems not working as expected. Attached is sample data Before and After in sheet1. I have done manual by custom sort.

    Sub MultiSort)
        Dim xRg As Range 'Declare range for Columns
        Dim yRg As Range 'Declare range for Rows
        Dim ws As Worksheet 'Name the WorkSheet
        Set ws = ActiveSheet
        On Error Resume Next
        Set xRg = Application.InputBox(Prompt:="Range Selection:", _
                                        Title:="Sort Multiple Columns", Type:=8)
        Application.ScreenUpdating = False
        For Each yRg In xRg
            With ws.Sort
                .SortFields.Clear
                .SortFields.Add(Key:=yRg, Order:=xlAscending, _
                 SortOn:=xlSortOnCellColor).SortOnValue.Color = vbGreen
                .SetRange ws.Range(yRg, yRg.End(xlDown))
                .Header = xlNo
                .MatchCase = False
                .Apply
            End With
        Next yRg
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort columns B,C,D based on column B then loop to next 3 columns and repeat till last colu
    By Andy15 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-09-2017, 05:35 PM
  2. Sort alphabetic with VBA on Range till last row
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2014, 07:49 AM
  3. Sum till the column till the date match
    By ursanil in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2014, 06:29 AM
  4. Copy entire selected column to next columns till last column
    By siroos12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2013, 05:20 AM
  5. [SOLVED] sort till last row
    By pedjvak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2012, 05:27 AM
  6. [SOLVED] Identify the last filled row in Column A and then drag formula in Column B till the same
    By bonny24tycoon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2012, 10:50 AM
  7. Replies: 2
    Last Post: 02-18-2005, 10:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1