Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I need to create a macro to sort 659 rows by 46 columns. The rows contain
numeric values that need to be sorted for lowest (left) to highest (right). When I sort manually left to right, the values for every row are not sorted correctly. Additionally when I sort manually, the left column in some rows are blank. This is a spreadsheet that has cells that have been manually updated. Macro below Sub SortLefttoRight() ' ' SortLefttoRight Macro ' Macro recorded 12/1/2007 by Carlton A. Barlow ' ' Range("G15:AZ673").Select Range("AZ673").Activate Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub All help is greatly appreciated |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Range("G15:AZ673").Sort Key1:=Range("G15"), Order1:=xlAscending,
Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub is column G the primary column? |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Column G should be the lowest value when sorting is complete.
"D." wrote: Range("G15:AZ673").Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub is column G the primary column? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This worked on a smaller test range.
Sub SortLefttoRight() ' ' SortLefttoRight Macro ' Macro recorded 12/1/2007 by Carlton A. Barlow ' ' Range("G15:O31").Select For Each cell In Range("G15:G31") Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next End Sub Gord Dibben MS Excel MVP On Sun, 2 Dec 2007 06:01:01 -0800, Carlton A. Barlow wrote: Column G should be the lowest value when sorting is complete. "D." wrote: Range("G15:AZ673").Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub is column G the primary column? |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Gord,
I modified your macro to include my range and when I run the macro it just loops and never finishes. Also none of the cells in the range are sorted correctly. The modifications I made are below. Range("G15:AZ673").Select For Each cell In Range("G15:AZ673") Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next End Sub "Gord Dibben" wrote: This worked on a smaller test range. Sub SortLefttoRight() ' ' SortLefttoRight Macro ' Macro recorded 12/1/2007 by Carlton A. Barlow ' ' Range("G15:O31").Select For Each cell In Range("G15:G31") Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next End Sub Gord Dibben MS Excel MVP On Sun, 2 Dec 2007 06:01:01 -0800, Carlton A. Barlow wrote: Column G should be the lowest value when sorting is complete. "D." wrote: Range("G15:AZ673").Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub is column G the primary column? |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Note the For Each range in my version is one column only.
Select the range to sort G15:AZ673 but the sort key is column G You must change your For Each range to For Each cell In Range("G15:G673") Gord On Sun, 2 Dec 2007 11:15:00 -0800, Carlton A. Barlow wrote: Gord, I modified your macro to include my range and when I run the macro it just loops and never finishes. Also none of the cells in the range are sorted correctly. The modifications I made are below. Range("G15:AZ673").Select For Each cell In Range("G15:AZ673") Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next End Sub "Gord Dibben" wrote: This worked on a smaller test range. Sub SortLefttoRight() ' ' SortLefttoRight Macro ' Macro recorded 12/1/2007 by Carlton A. Barlow ' ' Range("G15:O31").Select For Each cell In Range("G15:G31") Selection.Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next End Sub Gord Dibben MS Excel MVP On Sun, 2 Dec 2007 06:01:01 -0800, Carlton A. Barlow wrote: Column G should be the lowest value when sorting is complete. "D." wrote: Range("G15:AZ673").Sort Key1:=Range("G15"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal End Sub is column G the primary column? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sort Left-Right & Up-Down | Excel Worksheet Functions | |||
How do I create a Macro to sort data and insert blank rows & subto | Excel Worksheet Functions | |||
sorting alpha numeric list by first left digit | New Users to Excel | |||
Sort Macro to Exclude Blank Rows? | Excel Worksheet Functions | |||
Sort Left to Right | Excel Discussion (Misc queries) |