automatically import data from CSV to excel/calc s

2019-05-30 23:16发布

问题:

I have here 12 CSV source file (just numbers separated with semicolon).

I need on one action/click take this data and import it to excel/calc to 12 sheets (1 sheet for 1 csv source).

Any Idea how can I do that?

回答1:

you can do it with Excel vba:

  • create a new workbook (or use the current one depending on your needs)
  • ask the user to select several csv files (if they are on the same folder, else, you can ask the user if he still have some more to import) >> doc here
  • copy or move the imported worksheet to the new or current workbook (>> Excel 2003 VBA: Move a sheet into a new workbook that is referenced by a variable)

Please let us know if you encounter some trouble building your procedure



回答2:

By using the code in this post combined with a loop in which you step through the filenames (which you could keep in an array of string) and vary the .Destination with the sheets in the workbook(you can step through them by making as many new sheets as you need in the workbook and then going from Sheets(1) through Sheets(N), where N is the number of sheets.