Sort Data by colored cell.

Haroon Khan

New Member
Joined
Mar 6, 2019
Messages
3
Hi mrexcel forum.
I registered here by googling only to solve my problem. If this problem is solve than my task would be much much easier.
I have data on two column till 600 rows. first 300 is grayed and 2nd 300 is white. I want some kind of conditional formatting or filter or rule or anything to sort data in as first row is grayed then 2nd is white, and this sequence is going on to the end. if you don't understand what I m saying as english is not my 1st language then I m upload 2 screenshots for example, data on pic 1, and I need data in the sequence like in pic to.
(the answer to this is very urgent pls)

original data
Capture.jpg
[/URL][/IMG]

I want data as shown in the pic

Capture-2.jpg
[/URL][/IMG]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi Haroon

If you only want to do this once, and the data is exactly 300 grey rows then 300 white rows, then this approach should work.

Insert a new column to the left of your data.

In the first greyed row put 1 in column A
in the next greyed row put 3
Highlight both cells, and drag down all 300 rows - you should see 3,5,7 etc. all the way to 299
In the first white row put 2 in column A
In the next row put 4
Highlight both cells, and drag down all 300 rows - you should see 2.4.6 all the way to 300
Highlight all 600 rows and sort on clumn A
Finally, delete column A
 
Upvote 0
Another option
Change colours to suit !!
Code:
[COLOR="Navy"]Sub[/COLOR] MG06Mar30
[COLOR="Navy"]Dim[/COLOR] Ray1 [COLOR="Navy"]As[/COLOR] Variant, Ray2 [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray1 = Range("C3").Resize(300, 2)
Ray2 = Range("C303").Resize(300, 2)
 c = 2
 [COLOR="Navy"]For[/COLOR] n = 1 To UBound(Ray1, 1)
    c = c + 1
    Cells(c, "C") = Ray1(n, 1)
    Cells(c, "D") = Ray1(n, 2)
    Cells(c, "C").Resize(, 2).Interior.Color = vbYellow
    c = c + 1
    Cells(c, "C") = Ray2(n, 1)
    Cells(c, "D") = Ray2(n, 2)
    Cells(c, "C").Resize(, 2).Interior.Color = vbWhite

[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi Haroon

If you only want to do this once, and the data is exactly 300 grey rows then 300 white rows, then this approach should work.

Insert a new column to the left of your data.

In the first greyed row put 1 in column A
in the next greyed row put 3
Highlight both cells, and drag down all 300 rows - you should see 3,5,7 etc. all the way to 299
In the first white row put 2 in column A
In the next row put 4
Highlight both cells, and drag down all 300 rows - you should see 2.4.6 all the way to 300
Highlight all 600 rows and sort on clumn A
Finally, delete column A

hell yeah.. it is works. quite simple it is. thanks alot jmacleary. you are a life savior.
 
Upvote 0
Another option
Change colours to suit !!
Code:
[COLOR=Navy]Sub[/COLOR] MG06Mar30
[COLOR=Navy]Dim[/COLOR] Ray1 [COLOR=Navy]As[/COLOR] Variant, Ray2 [COLOR=Navy]As[/COLOR] Variant, n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] c [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long[/COLOR]
Ray1 = Range("C3").Resize(300, 2)
Ray2 = Range("C303").Resize(300, 2)
 c = 2
 [COLOR=Navy]For[/COLOR] n = 1 To UBound(Ray1, 1)
    c = c + 1
    Cells(c, "C") = Ray1(n, 1)
    Cells(c, "D") = Ray1(n, 2)
    Cells(c, "C").Resize(, 2).Interior.Color = vbYellow
    c = c + 1
    Cells(c, "C") = Ray2(n, 1)
    Cells(c, "D") = Ray2(n, 2)
    Cells(c, "C").Resize(, 2).Interior.Color = vbWhite

[COLOR=Navy]Next[/COLOR] n
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick

this is beyond my excel skills. but thanks anyway.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top