Results 1 to 3 of 3

filter csv, and import

Threaded View

  1. #1
    Registered User
    Join Date
    10-13-2012
    Location
    newcastle
    MS-Off Ver
    Excel 2007
    Posts
    68

    filter csv, and import

    Hello

    I need to import large csv files ino a single table everyday. I currently have a piece of code that goes through the folder containing csv files and imports the the data into my access table.

    How would i go about filtering each csv file based on the contents in column 1, before importing the filtered contents into access.

    The code so far is:

    Sub Import_multiple_csv_files()
         'Modified from WillR - www.willr.info (December 2004)
         
        Const strPath As String = "C:\Users\data\Desktop\data\" 'Directory Path
        Dim strFile As String 'Filename
        Dim strFileList() As String 'File  Array
        Dim intFile As Integer 'File Number
         
         'Loop through the folder & build file list
        strFile = Dir(strPath & "*.csv")
        While strFile <> ""
             'add files to the list
            intFile = intFile + 1
            ReDim Preserve strFileList(1 To intFile)
            strFileList(intFile) = strFile
            strFile = Dir()
        Wend
         'see if any files were found
        If intFile = 0 Then
            MsgBox "No files found"
            Exit Sub
        End If
         'cycle through the list of files &  import to Access
         'creating a new table called MyTable
        For intFile = 1 To UBound(strFileList)
            DoCmd.TransferText acImportDelimi, , _
            "data", strPath & strFileList(intFile)
             'Check out the TransferSpreadsheet options in the Access
             'Visual Basic Help file for a full description & list of
             'optional settings
        Next
        MsgBox UBound(strFileList) & " Files were Imported"
    End Sub
    Last edited by davesexcel; 09-07-2013 at 08:05 PM. Reason: Code Tags Added

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel 2007 : [XML] import -> filter -> export
    By beeryourself in forum Excel General
    Replies: 9
    Last Post: 10-29-2013, 09:40 AM
  2. filter messing up my import macro
    By matt3m in forum Excel General
    Replies: 1
    Last Post: 04-26-2012, 08:48 PM
  3. Import and Filter Data from Access
    By RunrChic01 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-27-2008, 10:31 PM
  4. Data Import and Filter
    By Josh O. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2005, 03:05 PM
  5. Import filter and update master
    By Mikeice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2005, 09:05 AM

Tags for this Thread

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