Pulling report from SQL

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, i have the following code which runs ( slowly) to pull two reports from an SQL internet database, just seems to run slowly, have had timer on the last few days and it takes between 294 seconds and 684 seconds to complete. my problem is that when i use debug step through it only takes 148 seconds.

Is there a reason why it takes so much longer when left to run from start to finish.

Dim t
t = Timer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual

Sheets("checksmart").Visible = xlSheetVisible
Sheets("checks").Visible = xlSheetVisible
Sheets("Info").Select
Calculate

Qlink = Sheets("Info").Range("A56").Value

Sheets("checkSmart").Select

Range("A1:AZ50000").Select
Selection.ClearContents
Range("L:L").NumberFormat = "dd/mm/yyyy mm.hh"
Range("u:u").NumberFormat = "dd/mm/yyyy mm.hh"
ActiveWorkbook.XmlImport URL:=Qlink, ImportMap:=Nothing, Overwrite:=True, Destination:=Range("$A$1")

Sheets("Info").Select


Qlink = Sheets("Info").Range("A69").Value

Sheets("checks").Select

Range("A1:AZ50000").Select
Selection.ClearContents

ActiveWorkbook.XmlImport URL:=Qlink, ImportMap:=Nothing, Overwrite:=True, Destination:=Range("$A$1")

Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
Sheets("checksmart").Visible = xlSheetHidden
Sheets("checks").Visible = xlSheethiddden

Sheets("instructions").Select
MsgBox Round(Timer - t, 2) & "sec."
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Are you clearing all existing data before loading up new data, personally I would delete the current sheet and create a new one with same name rather than selecting a huge range unless of course you have formulas on the worksheet
 
Upvote 0
Thanks, apart from formatting no formulas, will google to find out how to code in new sheet
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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