Remove .Select from Sort

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi, can anyone help?

I want to remove .Select from the Sort to make things run more smoothly


Code:
            .Range("A2:K" & lRowA).Select
            .Range(Selection, Selection.End(xlDown)).Select
            ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
            ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("E2:E" & lRowA), _
                SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
                "1,2,3,4,5,6,7" _
                , DataOption:=xlSortNormal
        
                With ActiveWorkbook.Worksheets("Sheet1").Sort
                    .SetRange Range("A2:K" & lRowA)
                    .Header = xlGuess
                    .MatchCase = False
                    .Orientation = xlTopToBottom
                    .SortMethod = xlPinYin
                    .Apply
                End With


Regards

pwill
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This did the trick,

Code:
        With Sheet1
            SetRange = Range("A2:K" & lRowA)
            .Sort.SortFields.Clear
            .Sort.SortFields.Add Key:=Range("E2:E" & lRowA), _
                SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
                "1,2,3,4,5,6,7" _
                , DataOption:=xlSortNormal
        
                With ActiveWorkbook.Worksheets("Sheet1").Sort
                    .SetRange Range("A2:K" & lRowA)
                    .Header = xlGuess
                    .MatchCase = False
                    .Orientation = xlTopToBottom
                    .SortMethod = xlPinYin
                    .Apply
                End With
        End With


pwill
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
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