riyajshaikh7
New Member
Hi Guys , I need your help. I have made a macro to copy filtered data from one sheet to another. The pasted data is going to be used for updating one graph. But running the macro took more than a minute to run which seems too bad
Could you please suggest how I can improve this code:-
Public Sub UpdateGraph()
Application.StatusBar = "Updating Graph........Please Wait 5 Seconds!!!!!!"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Sheets("Daily % LTOK data").Visible = True
Dim s As String
s = Sheets("Daily % LTOK data").Range("B2").Value
Sheets("Daily % LTOK data").Select
Range("$b$6:$d$60").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("$B$6").Select
Sheets("CP Monitoring").Select
ActiveSheet.Range("$E$8:$N$2500").AutoFilter Field:=1, Criteria1:=s
Range("$E$8:$G80").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Daily % LTOK data").Select
Range("$B$5").Select
ActiveSheet.Paste
Sheets("CP Monitoring").Select
ActiveSheet.Range("$E$8:$N$5000").AutoFilter
Range("a1").Select
Sheets("Daily % LTOK").Select
Application.CutCopyMode = False
Sheets("Daily % LTOK data").Visible = False
Application.StatusBar = "Done !"
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Many thanks !
Could you please suggest how I can improve this code:-
Public Sub UpdateGraph()
Application.StatusBar = "Updating Graph........Please Wait 5 Seconds!!!!!!"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Sheets("Daily % LTOK data").Visible = True
Dim s As String
s = Sheets("Daily % LTOK data").Range("B2").Value
Sheets("Daily % LTOK data").Select
Range("$b$6:$d$60").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("$B$6").Select
Sheets("CP Monitoring").Select
ActiveSheet.Range("$E$8:$N$2500").AutoFilter Field:=1, Criteria1:=s
Range("$E$8:$G80").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Daily % LTOK data").Select
Range("$B$5").Select
ActiveSheet.Paste
Sheets("CP Monitoring").Select
ActiveSheet.Range("$E$8:$N$5000").AutoFilter
Range("a1").Select
Sheets("Daily % LTOK").Select
Application.CutCopyMode = False
Sheets("Daily % LTOK data").Visible = False
Application.StatusBar = "Done !"
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Many thanks !