Entire Row Sort

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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Nest this in your unprotect-protect stuff. I should do what I think you question described, not sure how it relates to the code you posted though.

Rows("5:22").Sort Key1:=Range("b2"), Order1:=xlAscending, Header:=xlNo


I hope this helps.

Ken
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top