+ Reply to Thread
Results 1 to 3 of 3

How to select all .csv files within a folder and then import them.

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    23

    How to select all .csv files within a folder and then import them.

    Hi guys,

    I am new to VBA and I'm trying to automate a procedure that imports 4 .csv files in a specific folder to the SQL database.
    I have a code in which I have 4 command buttons and in each 4, I am picking the files and then importing them to SQL. However, I wanted to know if there is a way in which I can have just 1 command button that picks all the .csv files from that specific folder and then imports them to SQL. Assume the folder name is Database in the following path: Y:\Data\Database

    I have the following import button code that converts the local path to SQL server path and all other sorts of functions to import the data to SQL server. (fName1...fName4 are the TextBox values for the 4 file paths currently being picked by the user)

    Please Login or Register  to view this content.



    Any help on how to grab all 4 .csv files in a folder with a command button and then importing them would be appreciated!
    Thank you so much!

  2. #2
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,164

    Re: How to select all .csv files within a folder and then import them.

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: How to select all .csv files within a folder and then import them.

    thank you!

+ Reply to Thread

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