Runtime in Data Dump Comparision (ADODB in VBA)

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

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!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,884
Messages
6,127,562
Members
449,385
Latest member
KMGLarson

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