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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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