+ Reply to Thread
Results 1 to 2 of 2

Code to select, and then open CSV file into an Excel sheet

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2003 & Excel 2010
    Posts
    1

    Code to select, and then open CSV file into an Excel sheet

    Hello,
    I am relatively new at VBA, so thanks in advance for any help.

    I have a program that automatically exports a CSV file. I am trying to develop a macro that 1) prompts the user to select the file, then 2) imports the data into a blank sheet in Excel.

    My thoughts so far would be to have a macro that renames the CSV file as .XLS, then use text to columns to format the data. From there, I can have it copy the data.

    Any help would be greatly appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Code to select, and then open CSV file into an Excel sheet

    For 1), use Application.GetOpenFilename.

    For 2), record a macro with you manually opening the .csv file in Excel (File - Open, completing the Text to Columns wizard if it is displayed). Copy the opened .csv worksheet to the destination workbook.

    Edit the generated code to use the file name returned from 1) instead of the hard-coded file name in 2), checking that the GetOpenFilename return value is not False.
    Post responsibly. Search for excelforum.com

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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