![]() |
Sorting row data?!
Hi everyone,
I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo |
Sorting row data?!
If i get what you are asking select the area you want to sort, go to Data-
Sort select Options and change the Orientation box to Left and Right then select your row to sort by. -- -John Please rate when your question is answered to help us and others know what is helpful. "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo |
Sorting row data?!
I asssume you want to sort each row, from left to right and that you're
looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo |
Sorting row data?!
On Aug 15, 10:14 am, John Bundy (remove) wrote:
If i get what you are asking select the area you want to sort, go to Data- Sort select Options and change the Orientation box to Left and Right then select your row to sort by. -- -John Please rate when your question is answered to help us and others know what is helpful. "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - John, That what I did with one row, but how it can be done for 5000 rows; each row by itself.....it is none sens to do it 5000 times |
Sorting row data?!
On Aug 15, 10:22 am, Vergel Adriano
wrote: I asssume you want to sort each row, from left to right and that you're looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - Vergel, Are you sure it is correct? I am getting these two rows in RED: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight |
Sorting row data?!
Jo,
The newsreader wrapped the text to the next line. Make sure you put this in just one line: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 10:22 am, Vergel Adriano wrote: I asssume you want to sort each row, from left to right and that you're looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - Vergel, Are you sure it is correct? I am getting these two rows in RED: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight |
Sorting row data?!
On Aug 15, 11:18 am, Vergel Adriano
wrote: Jo, The newsreader wrapped the text to the next line. Make sure you put this in just one line: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 10:22 am, Vergel Adriano wrote: I asssume you want to sort each row, from left to right and that you're looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - Vergel, Are you sure it is correct? I am getting these two rows in RED: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight- Hide quoted text - - Show quoted text - What if I don't want the whole row but a range of rows I highlight 1st? Reason is the 1st cell in in each row is somehow an ID code (number too) which I don't sorting to touch!...... |
Sorting row data?!
Jo,
To skip the first cell of each row, do it this way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Offset(0, 1).Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Header:=xlYes, Orientation:=xlLeftToRight Next r End Sub To sort the rows in a range that you will select first, then this way: Sub test2() Dim r As Range For Each r In Selection.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 11:18 am, Vergel Adriano wrote: Jo, The newsreader wrapped the text to the next line. Make sure you put this in just one line: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 10:22 am, Vergel Adriano wrote: I asssume you want to sort each row, from left to right and that you're looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - Vergel, Are you sure it is correct? I am getting these two rows in RED: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight- Hide quoted text - - Show quoted text - What if I don't want the whole row but a range of rows I highlight 1st? Reason is the 1st cell in in each row is somehow an ID code (number too) which I don't sorting to touch!...... |
Sorting row data?!
On Aug 15, 11:52 am, Vergel Adriano
wrote: Jo, To skip the first cell of each row, do it this way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Offset(0, 1).Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Header:=xlYes, Orientation:=xlLeftToRight Next r End Sub To sort the rows in a range that you will select first, then this way: Sub test2() Dim r As Range For Each r In Selection.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 11:18 am, Vergel Adriano wrote: Jo, The newsreader wrapped the text to the next line. Make sure you put this in just one line: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight -- Hope that helps. Vergel Adriano "Jo" wrote: On Aug 15, 10:22 am, Vergel Adriano wrote: I asssume you want to sort each row, from left to right and that you're looking for a macro to do that. Here's one way: Sub test() Dim r As Range For Each r In ActiveSheet.UsedRange.Rows r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight Next r End Sub -- Hope that helps. Vergel Adriano "Jo" wrote: Hi everyone, I know how to sort data by row, but say I have 5000 or more rows! Going to each row and doing the sorting is time-consuming. Is there a smart way to do this one time? Thanks, Jo- Hide quoted text - - Show quoted text - Vergel, Are you sure it is correct? I am getting these two rows in RED: r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending, Orientation:=xlLeftToRight- Hide quoted text - - Show quoted text - What if I don't want the whole row but a range of rows I highlight 1st? Reason is the 1st cell in in each row is somehow an ID code (number too) which I don't sorting to touch!......- Hide quoted text - - Show quoted text - Yes it helps, thanks. One more question, say after sorting I want to no repetitive values per row. So, If after sorting I get 12, 12, 13, 14 I want the result to be 12, 13, 14.......what else I should add to the code to add this feature? Thanks again.... |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com