J
John
I have a macro (detailed below) which is really slow at running, approx 10
mins, but doesnt have a substantial amount of information. Should I be
turning off Caluculation within it or will it effect some of the formulas I
add within the macro?
Sub GoToFigures()
Format_Query
Sheets("Database2").Visible = True
Sheets("Database2").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A1").Select
Application.ScreenUpdating = False
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Sheets("Database2").Select
Range("A1").Select
Columns("B:B").Select
Application.CutCopyMode = False
Selection.NumberFormat = "DD/MM/YY"
Range("N2").Select
ActiveCell.Formula =
"=IF(ISNA(MATCH(A2,StaffNo,0)),""Crew"",INDEX(StaffGrade,MATCH(A2,StaffNo,0)))"
Range("N2.N2").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 14).PasteSpecial xlPasteFormulas
x = x + 1
Loop
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database2").Select
Range("A1").Select
ActiveWindow.SelectedSheets.Visible = False
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database3").Visible = True
Sheets("Database3").Select
Sheets("Database3").Select
ActiveSheet.Unprotect Password:="pass"
Cells.Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A1").Select
Application.ScreenUpdating = False
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Range("B11").Select
Range("A1").Select
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database3").Select
Range("A1").Select
ActiveWindow.SelectedSheets.Visible = False
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
EmployeeNumbers
Sheets("Figures").Select
ActiveSheet.Protect Password:="pass", DrawingObjects:=True,
Contents:=True, Scenarios:=True
Range("B11").Select
Range("B11").Select
End Sub
mins, but doesnt have a substantial amount of information. Should I be
turning off Caluculation within it or will it effect some of the formulas I
add within the macro?
Sub GoToFigures()
Format_Query
Sheets("Database2").Visible = True
Sheets("Database2").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A1").Select
Application.ScreenUpdating = False
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Sheets("Database2").Select
Range("A1").Select
Columns("B:B").Select
Application.CutCopyMode = False
Selection.NumberFormat = "DD/MM/YY"
Range("N2").Select
ActiveCell.Formula =
"=IF(ISNA(MATCH(A2,StaffNo,0)),""Crew"",INDEX(StaffGrade,MATCH(A2,StaffNo,0)))"
Range("N2.N2").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 14).PasteSpecial xlPasteFormulas
x = x + 1
Loop
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database2").Select
Range("A1").Select
ActiveWindow.SelectedSheets.Visible = False
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database3").Visible = True
Sheets("Database3").Select
Sheets("Database3").Select
ActiveSheet.Unprotect Password:="pass"
Cells.Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A1").Select
Application.ScreenUpdating = False
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Range("B11").Select
Range("A1").Select
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
Sheets("Database3").Select
Range("A1").Select
ActiveWindow.SelectedSheets.Visible = False
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True
EmployeeNumbers
Sheets("Figures").Select
ActiveSheet.Protect Password:="pass", DrawingObjects:=True,
Contents:=True, Scenarios:=True
Range("B11").Select
Range("B11").Select
End Sub