Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Sorting Macro Loop
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="anduare2, post: 6392509"] I have recorded a macro and am playing with it in Visual Basic (excel 2003). I copy data to a new sheet with values only and now I want to sort all the columns individually to get the valid data to the top and spaces to the bottom. My macro can do this, coded with the following sort commands but i think it would be more efficient to run it as a loop condition. My columns will alway start in Columns("A:A").Select. Can i do something like Range (Selection, Selection.End(xlToRight)).Select -- starting in column A then pass this value to the loop variable and sort from column A to the end of that variable column. example body of sort commands to turn into loop procedure Columns("A:A").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Columns("B:B").Select Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Columns("C:C").Select Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Columns("D:D").Select Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal appreciate any ideas, Thanks [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Sorting Macro Loop
Top