Sorting macro

hitbid

Board Regular
Joined
Jan 21, 2016
Messages
114
The problem here is I am poor at creating sorting macros, and use the recorder, and tried to implement a variable for the bottom row. This is an easy fix, right?

I am getting error for this, "doesn't support this property or method".
The first error is in Bold below.
B_Row is defined just fine, and equals 335 when I float the mouse over it.


Code:
    ActiveWorkbook.Worksheets("EQ").Sort.SortFields.Clear
    With ActiveWorkbook.Worksheets("EQ").Sort
[B]        .SortFields.Add2 Key:=Range("E1:E" & B_Row), _[/B]
[B]        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal[/B]
        .SortFields.Add2 Key:=Range("C1:C" & B_Row), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SortFields.Add2 Key:=Range("A1:A" & B_Row), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SetRange Range("A1:K" & B_Row)
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Son of.....

Yep, thanks again, always a reliable response from you. Appreciate it.

No clue why I had it like that.
 
Upvote 0
You're welcome & thanks for the feedback.
I think it's something that came in with 2016, but not sure what Add2 does.
I've just seen other members saying to change it.
 
Upvote 0
Makes sense. I created the macro at home on a newer version of excel, 2016, and tried to just drop it into the work computer.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
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