Macro To Importing Several CSV Files into Access

Lucas in London

Board Regular
Joined
Jun 17, 2002
Messages
88
Hi,

I have about 25 CSV files located in a folder that I want to open in access as separate tables within one database. All files are identical in the sense that they all contain only two fields (Coolum 1 date field, column 2 data), the top rows contains column headers. The only thing that is different between the files in the data content and so the length of fields (number of rows).

Opening/importing each file is taking a while and was wondering if I could import all the files using some kind of macro? I'm thinking this should be easy given that I have to go through identical steps to import each file:

1) Get external Data - Import File and select my file
2) Select Comma Delimited in the next window
3) Click first row Contains field names in next window
4) Click import into a new table in next window
5) Do not assign a Primary key

I am completely new to macros for Access – do not even now how to record! So any help will be much appreciated.

Thanks,

Lucas
 
Ok, I've done some investigation into union querys and based on this I've created the following union query based around the SQL syntax used in Access.

However when I ran the query I get a message saying "the number of columns in the two selected tables or queries of a union query do not match". I looked on-line and found that union queries only work where the tables have the same number of feilds. Is this true?

If not, would be grateful if someone could have a look at my SQL code below. Just to recap - I want to bring back all feilds and all rows data from the three tables below using the date feild as the join accross the tables. I want to bring back all rows - matched and unmatched from the tables, known as a full outer join I believe!

Thanks,

Lucas

SELECT *
FROM
BOE LEFT JOIN indices ON boe.date=indices.date
UNION select *
from
technicals LEFT JOIN boe ON technicals.date=boe.date;
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,113
Messages
6,170,171
Members
452,306
Latest member
Shaz11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top