Add Sort Condition

The Animal

Active Member
Joined
May 26, 2011
Messages
449
Hi
I have the below sort which just uses I4:I28 etc as the asending sort what would below look like if I wanted to firstly sort F4:F28 in the order "Active then Inactive then extra" and then sort I4:I28 ascending for below rows

Sub TestSort()
ActiveSheet.Unprotect
Range("4:28").Sort Range("I4:I28"), Order1:=xlAscending, Header:=xlNo
Range("34:37").Sort Range("I34:I37"), Order1:=xlAscending, Header:=xlNo
Range("43:48").Sort Range("I43:I48"), Order1:=xlAscending, Header:=xlNo
Range("54:66").Sort Range("I54:I66"), Order1:=xlAscending, Header:=xlNo
Range("72:97").Sort Range("I72:I97"), 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

Any help would be great
Stephen
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,223,628
Messages
6,173,429
Members
452,514
Latest member
cjkelly15

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