g48dd
Board Regular
- Joined
- Jan 12, 2009
- Messages
- 101
Excel 2003: I have this from the macro recorder:
Is there a better way to get the same thing done? Header row is on O10 but it's not necessary to include it, I do need it ascending, I will sort columns P,Q,R,S,T,U,V, & W. What I am doing is sorting the range O10:W25 but I sort it by column P then I copy column O10:O20 and paste it the next sheet (sheet 7) cell I10, then go back and get Column P10:P20 & paste that in Sheet 7 J10, then go back and sort the whole range O10:W25 again but this time by column Q, then copy O10:O20 and paste it to sheet 7 cell L10; go back and get Q10:Q20 paste that to M10 ect.. I can do the back and forth stuff with
and I can just copy what the macro recorder has done but usually there is a better way and that is why I am asking. I know it looks silly but this is just a sample in reality I am working with 200 rows and taking the bottom 10, that is why it is sorted ascending, and I always have to have Column O with what ever column I am sorting as column O is the name.
Thank you
Ken
Code:
Range("O10:W25").Select
Selection.Sort Key1:=Range("P11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Is there a better way to get the same thing done? Header row is on O10 but it's not necessary to include it, I do need it ascending, I will sort columns P,Q,R,S,T,U,V, & W. What I am doing is sorting the range O10:W25 but I sort it by column P then I copy column O10:O20 and paste it the next sheet (sheet 7) cell I10, then go back and get Column P10:P20 & paste that in Sheet 7 J10, then go back and sort the whole range O10:W25 again but this time by column Q, then copy O10:O20 and paste it to sheet 7 cell L10; go back and get Q10:Q20 paste that to M10 ect.. I can do the back and forth stuff with
Code:
[O10:O20].Copy Destination:=Sheets(ActiveSheet.Index +1).[I10]
and I can just copy what the macro recorder has done but usually there is a better way and that is why I am asking. I know it looks silly but this is just a sample in reality I am working with 200 rows and taking the bottom 10, that is why it is sorted ascending, and I always have to have Column O with what ever column I am sorting as column O is the name.
Thank you
Ken