tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have a slow filter code that takes about 3 seconds to run
i'm woundering if it can be speed up somehow?
this is what I have at the moment
Any ideas would be a great help
Thanks
Tony
I have a slow filter code that takes about 3 seconds to run
i'm woundering if it can be speed up somehow?
this is what I have at the moment
VBA Code:
Sub Dashboard_Filter()
On Error GoTo EH
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Sheets("PDD").Columns("C:C").NumberFormat = "General"
LastrowDash1 = Sheets("Profitability Dashboard").Cells(Rows.Count, "AC").End(xlUp).Row
If LastrowDash1 < 102 Then
LastrowDash1 = 102
End If
LastCol1 = Sheets("Profitability Dashboard").Range("AB100").Value
Application.ScreenUpdating = False
Sheets("Profitability Dashboard").Range("AC102:AR" & LastrowDash1).ClearContents
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("PDD").Range("$A2:$O2").AutoFilter
Status = Sheets("Dashboard Data1").Range("B10").Value
startM = Sheets("Dashboard Data1").Range("B12").Value
endM = Sheets("Dashboard Data1").Range("B14").Value
Client = Sheets("Dashboard Data1").Range("B18").Value
Cat = Sheets("Dashboard Data1").Range("B20").Value
Focus = Sheets("Dashboard Data1").Range("B22").Value
Project = Sheets("Dashboard Data1").Range("B24").Value
EM = Sheets("Dashboard Data1").Range("B26").Value
PM = Sheets("Dashboard Data1").Range("B28").Value
NCL = "No Capacity Logged!"
LrowFit1 = Sheets("PDD").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=13, Criteria1:="<>" & NCL
If startM <> 0 Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=3, Criteria1:=">=" & startM
Else
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=3, Criteria1:=">=01/01/2016"
End If
If endM <> 0 Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=15, Criteria1:="<=" & endM
End If
If Client <> 0 Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=4, Criteria1:=Client
End If
'''''''
If Status <> 0 Then
If Status = "Current/Completed" Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=12, Criteria1:=Array("Current", "Completed"), Operator:=xlFilterValues
Else
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=12, Criteria1:=Status
End If
End If
'''''
If Project <> 0 Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=6, Criteria1:=Project
End If
If Cat <> 0 Then
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=5, Criteria1:=Cat
End If
If Focus <> 0 Then
Application.ScreenUpdating = False
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=9, Criteria1:=Focus
End If
If EM <> 0 Then
Application.ScreenUpdating = False
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=7, Criteria1:=EM
End If
If PM <> 0 Then
Application.ScreenUpdating = False
Sheets("PDD").Range("$A$2:$O$" & LrowFit1).AutoFilter Field:=8, Criteria1:=PM
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
EH:
Sheets("Dashboard Data1").Visible = False
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
Any ideas would be a great help
Thanks
Tony