Here is my ADO with speed tests. I copied the xlsx file's data down to 100001 rows for 100000 check.
'Sub GetData()
'87/16999 desktop 1.90, 1.34, laptop 3.49, 4.93
' 522/100000 laptop 19.47, 19.34
'Sub GetData2()
'87/16999 desktop 0.88, 0.87, laptop 2.38, 2.33
'522/100000 laptop 10.73, 8.75
Sub GetData3()
'522/100000 laptop 3.10, 3.21, 4.49
'An ADO Method
Dim FileName$, dDate&, arrData, time1#, time2#, sql$, sConn$
time1 = Timer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
With ThisWorkbook.Sheets("Variables")
dDate = .Range("A4").Value
FileName = .Range("A8").Value
End With
'Clear existing List data rows.
With ThisWorkbook.Worksheets("List")
.Range("A2", .Cells(Rows.Count, "I").End(xlUp)).ClearContents
End With
With CreateObject("ADODB.connection")
'https://www.connectionstrings.com/excel/
sConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
FileName & ";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
.Open sConn
sql = "SELECT * FROM [" & shWindow1 & "$A:I] where [Trading Date]=" & dDate
Worksheets(shList).Range("A2").CopyFromRecordset .Execute(sql)
.Close
End With
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
time2 = Timer
MsgBox Format(time2 - time1, "0.00 \s\ec")
End Sub
Bookmarks