Multiple Use of Filters in Macro

JamesUKnow

New Member
Joined
Feb 8, 2014
Messages
5
Hi There,

I need to perform a series of filters/sorts on a data table of sales opportunities.

I have recorded a macro and attached to a function button which works well from a results perspective but is very slow.

Not sure if this is something to do with my laptop, the macro of the data set.

The data table is 1000 lines long, currently only populated with c.100 entries and 50 columns wide, most of which are blank or filled with "---".

The macor is as follows:

Sub Filter_Expected()
'
' Filter_Expected Macro
'


'
Rows("8:8").Select
Selection.AutoFilter
Selection.AutoFilter
ActiveWindow.ScrollColumn = 33
ActiveWindow.ScrollColumn = 5
ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort.SortFields.Add Key _
:=Range("A8"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$8:$BH$1008").AutoFilter Field:=4, Criteria1:=Array( _
"Open", "Pending", "="), Operator:=xlFilterValues
ActiveSheet.Range("$A$8:$BH$1008").AutoFilter Field:=5, Criteria1:= _
"=Expected", Operator:=xlOr, Criteria2:="="
ActiveSheet.Range("$A$8:$BH$1008").AutoFilter Field:=3, Criteria1:="<>"
ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort.SortFields.Add Key _
:=Range("C8:C1008"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("New Template").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

Is there something wrong with the macro?

Would this be better done with VBA (of which I have virtually no experience.

Your advice would be appreciated.

Regards, James
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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