I have a tab and few pivot table. Everything was working fine but now because I added vlookup in the tab along with few formula it make the file VERY slow. Please note that I have a connection to ODBC and SQL to pull like 30,000 row and 32 column of data.
Is there a way that I could improve performance?
I tried: uncheck the background update added a wait for query
It is still very slow... take like 15 minutes to finish and open! Any help to reduce this would be appreciate!
Thanks,
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
DoEvents
ActiveWorkbook.RefreshAll
Application.CalculateUntilAsyncQueriesDone
If Not Application.CalculationState = xlDone Then
DoEvents
End If
DoEvents
Range("A3:P3").Select
Sheets("FRQ-4").Select
Range("A6").Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("STATUT")
.PivotItems("INACTIF").Visible = False
.PivotItems("(blank)").Visible = False
End With
ActiveSheet.Range("$A$3:$P$385").AutoFilter Field:=14, Criteria1:="=1", _
Operator:=xlOr, Criteria2:="=BESOIN-ACHAT " & Chr(10) & "1=OUI 0=NON"
DoEvents
Range("A3:P3").Select
Sheets("FRQ-3").Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("STATUT")
.PivotItems("INACTIF").Visible = False
.PivotItems("(blank)").Visible = False
End With
ActiveSheet.Range("$A$3:$P$385").AutoFilter Field:=14, Criteria1:="=1", _
Operator:=xlOr, Criteria2:="=BESOIN-ACHAT " & Chr(10) & "1=OUI 0=NON"
Range("A6").Select
DoEvents
Range("A3:P3").Select
Sheets("FRQ-2").Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("STATUT")
.PivotItems("INACTIF").Visible = False
.PivotItems("(blank)").Visible = False
End With
ActiveSheet.Range("$A$3:$P$385").AutoFilter Field:=14, Criteria1:="=1", _
Operator:=xlOr, Criteria2:="=BESOIN-ACHAT " & Chr(10) & "1=OUI 0=NON"
Range("A6").Select
DoEvents
Range("A3:P3").Select
Sheets("FRQ-1").Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("STATUT")
.PivotItems("INACTIF").Visible = False
.PivotItems("(blank)").Visible = False
End With
ActiveSheet.Range("$A$3:$P$385").AutoFilter Field:=14, Criteria1:="=1", _
Operator:=xlOr, Criteria2:="=BESOIN-ACHAT " & Chr(10) & "1=OUI 0=NON"
Range("A6").Select
Sheets("FRQ-4").Select
With ActiveSheet.Columns("E:S")
.HorizontalAlignment = xlCenter
End With
With ActiveSheet.Columns("A:D")
.HorizontalAlignment = xlLeft
End With
Sheets("FRQ-3").Select
With ActiveSheet.Columns("E:S")
.HorizontalAlignment = xlCenter
End With
With ActiveSheet.Columns("A:D")
.HorizontalAlignment = xlLeft
End With
Sheets("FRQ-2").Select
With ActiveSheet.Columns("E:S")
.HorizontalAlignment = xlCenter
End With
With ActiveSheet.Columns("A:D")
.HorizontalAlignment = xlLeft
End With
Sheets("FRQ-1").Select
With ActiveSheet.Columns("E:S")
.HorizontalAlignment = xlCenter
End With
With ActiveSheet.Columns("A:D")
.HorizontalAlignment = xlLeft
End With
MsgBox "Ready"
End Sub