The Animal
Active Member
- Joined
- May 26, 2011
- Messages
- 449
Hi
I have the below macro that that sorts for example ranges A5:CD22 based on B5:B22 sort selection.
How would it look if instead of selecting the specific ranges as above but rather I wanted to sort entire rows 5:22 based on B5:B22 sort selection?
Any help would be great.
Thanks Stephen
Sub TestSort()
ActiveSheet.Unprotect
Range("A5:CD22").Sort Range("B5:B22"), Order1:=xlAscending, Header:=xlNo
Range("A30:CD35").Sort Range("B30:B35"), Order1:=xlAscending, Header:=xlNo
Range("A46:CD58").Sort Range("B46:B58"), Order1:=xlAscending, Header:=xlNo
Range("A66:CD85").Sort Range("B66:B85"), Order1:=xlAscending, Header:=xlNo
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowFiltering:=True
End Sub
I have the below macro that that sorts for example ranges A5:CD22 based on B5:B22 sort selection.
How would it look if instead of selecting the specific ranges as above but rather I wanted to sort entire rows 5:22 based on B5:B22 sort selection?
Any help would be great.
Thanks Stephen
Sub TestSort()
ActiveSheet.Unprotect
Range("A5:CD22").Sort Range("B5:B22"), Order1:=xlAscending, Header:=xlNo
Range("A30:CD35").Sort Range("B30:B35"), Order1:=xlAscending, Header:=xlNo
Range("A46:CD58").Sort Range("B46:B58"), Order1:=xlAscending, Header:=xlNo
Range("A66:CD85").Sort Range("B66:B85"), Order1:=xlAscending, Header:=xlNo
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowFiltering:=True
End Sub