+ Reply to Thread
Results 1 to 4 of 4

VBA - csv file import

  1. #1
    Registered User
    Join Date
    01-15-2019
    Location
    UK
    MS-Off Ver
    Office 365 MSO
    Posts
    2

    VBA - csv file import

    Hi,

    I am very new to VBA (having only really used the record function before) and am working through the training resources.

    In the meantime I have a project where I am trying to achieve the following

    - Import the second most recent csv file in a folder into 'Sheet 1' making sure the first column imports as text.

    - Import the most recent csv file in the same folder into 'Sheet 2' making sure the seventh column imports as text.

    (both of the above are delimited by comma)

    I know this should be possible but after looking on various forums can't seem to get it to work correctly.

    I can get a specific file to import or a loop of files from a folder but this still leaves me with an issue with the correct columns not being formatted as text (there are often leading zeros in some of the data which I need to keep which is why this is required).

    Any assistance greatly appreciated!

    Thank you

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA - csv file import

    Hello AParrack,

    Welcome to the forum!

    Do you want the first and second most recent dates for any of CSV files in the same folder?

    Does most recent mean date last accessed or date created?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-15-2019
    Location
    UK
    MS-Off Ver
    Office 365 MSO
    Posts
    2

    Re: VBA - csv file import

    Hi Leith,

    Thanks for your reply.

    They are both downloaded files that are unopened/edited so both modified and accessed dates are the same.

    Sorry I should have put that in my original post!

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,546

    Re: VBA - csv file import

    As you are using the subscription version (365) have you tried and/or considered accomplishing what you are attempting using Power Query (AKA Get & Transform Data)?
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Import .xls file into .xlsm file and delete unwanted headings, blank rows.
    By pacificepoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2018, 12:50 AM
  2. Macro - Open File Explorer, Select File, Import certain information from file
    By Drayde in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2015, 08:58 AM
  3. Replies: 0
    Last Post: 05-28-2014, 02:45 AM
  4. [SOLVED] MACRO: Store name of selected file as string w/ import data file dialog box
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 02:13 PM
  5. [SOLVED] Macro - Master file to import data from another open file with variable file name
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2012, 10:56 PM
  6. File import - select file and import sheet(1) from closed workbook
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2011, 03:15 AM
  7. [SOLVED] How do I import text file, analyze data, export results, open next file
    By Geoffro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2005, 04:06 PM

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