Sort Data by colored cell.

Haroon Khan

New Member
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
[/URL][/IMG]

I want data as shown in the pic

[/URL][/IMG]

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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

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

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.

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.

Replies
3
Views
181
Replies
0
Views
117
Replies
11
Views
518
Replies
2
Views
165
Replies
1
Views
211

Threads
1,203,600
Messages
6,056,205
Members
444,850
Latest member
dancasta7

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

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