+ Reply to Thread
Results 1 to 5 of 5

Importing Data via Macro

  1. #1
    Registered User
    Join Date
    04-16-2009
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Importing Data via Macro

    Hi,
    I'm trying to write a macro for importing data, the macro will take the user to select data source window (Data > Import external data > Import data), where they can select a file they wish to import and the options in text import wizard have already been set (Delimited, file origin, delimiters, where to put the data, etc). I would like it to open automatically when the workbook is opened

    After that I would like to run another Macro that I have already written, which manipulates the data

    Is this possible?

  2. #2
    Registered User
    Join Date
    05-05-2009
    Location
    Europe, Earth
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    8

    Re: Importing Data via Macro

    Hi,

    Do you mean something like this?

    Please Login or Register  to view this content.
    If you open Excel you get a dialogwindow and you can select a file and import data from that file back to Excel. You can adjust it to how you want it.

  3. #3
    Registered User
    Join Date
    04-16-2009
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Importing Data via Macro

    Thanks,
    Yeah that works but is there a way to automate import wizard? Or do you need to chose the options each time (Delimiters - semicolon)?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Importing Data via Macro

    If the formatting of the file(s) that the user will select from is in a standard form, you can record a macro yourself of you selecting a file, setting all the options and importing the data...you can even leave the recorder going while you activate the other macro you've already written.

    Once you've recorded that, post the resulting macro here and we can help you automate the file selection process to streamline it.

    Be sure to GO ADVANCED and use the # icon...click on that first and then paste the code in between the [ code ] tags that appear.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    04-16-2009
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Importing Data via Macro

    Hi,
    I just realised that something weird happens when I import the data using the code above, it does not import the data correctly, it changes the formatting of some of the dates completely in what appears to be random way. (Dates appear in about 8 columns and all seem to be effected). A warning (error) message appears on the effected cells and asks for the dates to be convertered from 2-digit to 4-digit either 19xx or 20xx.

    If I manually import the data (Data > Import external data > Import data) its works and the data is correct.

    Is there another way to import data or correct this problem?
    Last edited by acs013; 05-18-2009 at 07:38 AM.

+ 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