ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting rows (https://www.excelbanter.com/excel-programming/389296-sorting-rows.html)

Lowell

Sorting rows
 
Hello, I hope you can provide me a solution to this problem. I have a series
of data as outlined below. The data list has over 4000 rows and I need to
sort each row in ascending order, while keeping the data association in
column A.


A B C D E F G

Date B1 B2 B3 B4 B5 B6
1 5/7/1988 3002 4419 1729 4934 4267 1507
2 5/14/1988 1885 1507 2366 1973 1154 2237
3 5/21/1988 1507 4093 812 4770 2563 2237
4 5/28/1988 3657 1227 1973 1372 2089 4841

When I am finished sorting I would like to be able to see the data :

1 5/7/1988 1507 1729 3002 4267 4419 4934
2 5/14/1988 1154 1507 1885 1973 2237 2366
3 5/21/1988 812 1507 2237 2563 4093 4770
4 5/28/1988 1227 1372 1973 2089 3657 4841

I have tried several methods but I have not found anything that really works
well. The best I have done is converting the data using data list but that
really does not help me.


--
Lowell Shoaf
Realtor
RE/MAX Gulfstream Realty
Sarasota, Florida

merjet

Sorting rows
 
Copy | Paste Special | Transpose the numbers to another range of
cells. Sort the result, each column independently. Copy | Paste
Special | Transpose the sorted numbers back to their original
location. Since you have 4000 rows (and unless you have Excel 2007),
you will have to do it in chunks. The following Sub should help with
the sorting. Change the number of columns, etc. to suit.

Sub Macro1()
Dim iEnd As Integer
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
iEnd = ws.Range("A1").End(xlDown).Row
For iCol = 1 To 4
ws.Range(Cells(1, iCol), Cells(iEnd, iCol)).Sort _
Key1:=Cells(2,iCol), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Next iCol
End Sub

Hth,
Merjet



merjet

Sorting rows
 
Interesting, indeed. Thanks!

Merjet



strive4peace

Sorting rows
 
you're welcome, Merjet ;)

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



merjet wrote:
Interesting, indeed. Thanks!

Merjet



strive4peace

Sorting rows
 
you're welcome, Lowell ;) happy to help


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Lowell wrote:
Thanks, your terrific, the sub routine worked perfectly.



All times are GMT +1. The time now is 04:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com