Results 1 to 33 of 33

Get matching values using ADO from closed CSV file

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Get matching values using ADO from closed CSV file

    Hi everyone,

    I have attached 2 sample files. I'm trying to get a kind of Vlookup from data that is in a more than 50 MB CSV file (comma delimeted).
    I want to lookup values in column A of "LookUpResults.xlsx" that match values in column A of "Origin.csv". For each matching row, put in
    column B values from column B, in C values from C, in D values from D.

    I've been trying some ADO codes in order to test but doesn't show any value.

    Some of the codes I've been testing without success is:
    (source: http://technet.microsoft.com/en-us/l.../ee692882.aspx)

    Sub LookUp_With_ADO()
    On Error Resume Next
    
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adCmdText = &H1
    
    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordset = CreateObject("ADODB.Recordset")
    
    objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\Scripts\Test.xls;" & _
            "Extended Properties=""Excel 8.0;HDR=Yes;"";"
    
    objRecordset.Open "Select * FROM [Sheet1$] Where Number = 2", _
        objConnection, adOpenStatic, adLockOptimistic, adCmdText
    
    Do Until objRecordset.EOF
        Wscript.Echo objRecordset.Fields.Item("Name"), _
            objRecordset.Fields.Item("Number")
        objRecordset.MoveNext
    Loop
    End Sub
    May somebody help me to get this working?

    * The Origin.csv files doesn't have headers.

    Many thanks in advance.

    Regards
    Attached Files Attached Files
    Last edited by cgkmal; 09-29-2011 at 03:02 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1