• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sorting of colored cells all at once.

SouthKaDaaku

New Member
Hello everyone,

I have a data file that contains many columns. Under each column there are cells that are colored and some that are blank.
I want to be sort the data in such a way that all the colored cells appear on top and the non colored cells below them.
I have manually sorted till column 25. Since there are multiple columns i want to do the sorting at once, by use of a VBA or Macro.

Sharing the sample file and a screenshot of the same.

1698307721174.png
 

Attachments

  • Chandoo Sort by Color Macro.xlsx
    29.2 KB · Views: 7
Hello, according to the attachment an Excel basics VBA demonstration for starters :​
Code:
Sub Demo1()
        Dim Rc As Range
        Application.ScreenUpdating = False
    For Each Rc In [A5].CurrentRegion.Columns
   With ActiveSheet.Sort
       .SortFields.Clear
       .Header = 2
       .SetRange Rc
       .SortFields.Add Rc, 1, 2
       .Apply
   End With
    Next
        Application.ScreenUpdating = True
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Thank you for your replies,

vletm ( I remember you have helped me with some other problem previously too :))

Marc L, for listing the code.

Thank you.
 
Back
Top