Colorations
Board Regular
- Joined
- Jun 13, 2016
- Messages
- 61
@Moderators/Admins, sorry for repost, but previous thread may have had sensitive information
The 'key' is an unique asset tag with properties associated with each asset tag. I am trying to find differences in these properties. Each dump is about 30,000 rows by 30 columns and each dump is on a separate workbook containing one worksheet each.
My approach was ADODB as I read that would be the fastest and most efficient; however, I am having problems with runtime as my program keeps timing out. The code is below
I'm pretty sure the part that slows the code down is at
I am open to all suggestions and comments
Thanks all!
The 'key' is an unique asset tag with properties associated with each asset tag. I am trying to find differences in these properties. Each dump is about 30,000 rows by 30 columns and each dump is on a separate workbook containing one worksheet each.
My approach was ADODB as I read that would be the fastest and most efficient; however, I am having problems with runtime as my program keeps timing out. The code is below
Code:
Set Connection1 = CreateObject("ADODB.Connection")
Set RecordSet1 = CreateObject("ADODB.Recordset")
Set Connection2 = CreateObject("ADODB.Connection")
Set RecordSet2 = CreateObject("ADODB.Recordset")
Connection1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & path1 & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
Connection2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & path2 & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
RecordSet2.Open "Select * FROM [Sheet1$]", _
Connection2, 0, 1
RecordSet2.MoveFirst
Dim currTag As String
Do Until RecordSet2.EOF
If RecordSet2.Fields(6).Value <> "" Then
currTag = RecordSet2.Fields(6).Value
On Error Resume Next
Sql = "Select * FROM [Sheet1$] " _
& "WHERE [Asset Tag]='" & currTag & "'"
Set RecordSet1 = Connection1.Execute(Sql, 0, 1)
End If
RecordSet2.MoveNext
Loop
RecordSet2.Close
Connection1.Close
Connection2.Close
Set RecordSet1 = Nothing
Set RecordSet2 = Nothing
Set Connection1 = Nothing
Set Connection2= Nothing
I'm pretty sure the part that slows the code down is at
Code:
Set RecordSet1 = Connection1.Execute(Sql, 0, 1)
I am open to all suggestions and comments
Thanks all!