gregggrown
New Member
- Joined
- Jan 4, 2010
- Messages
- 10
Hi all, I have a workbook where I need to sort data with range (K2:L24), then move down 208 rows and sort range (K210:L232) and repeat this upto 1000 times. I have shortened a recorded macro as an example and would like to know how to loop or repeat please.
Thanks
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/04/2011 by Greg
'
' Keyboard Shortcut: Ctrl+x
'
Range("K1:L24").Select
Selection.sort Key1:=Range("L2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K209:L232").Select
Selection.sort Key1:=Range("L210"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K417:L440").Select
Selection.sort Key1:=Range("L418"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K625:L648").Select
Selection.sort Key1:=Range("L626"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Thanks
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/04/2011 by Greg
'
' Keyboard Shortcut: Ctrl+x
'
Range("K1:L24").Select
Selection.sort Key1:=Range("L2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K209:L232").Select
Selection.sort Key1:=Range("L210"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K417:L440").Select
Selection.sort Key1:=Range("L418"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("K625:L648").Select
Selection.sort Key1:=Range("L626"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub