Excel to Access Data Transfer

derek_watt

New Member
Joined
Aug 4, 2011
Messages
1
Hi All,

Hopefully someone can help me a bit with this query. I'm currently working on an EXCEL VBA macro which will:

1. import a text file into EXCEL
2. trim all cells (the text file has white spaces around all text strings)
3. reformat column headers
4. remove blank rows (blank rows appear every ~10,000 rows)
5. edit rows where a delimiter was used in a text string - the semi-colon is my delimiter, sometimes this can appear in the middle of a text string such as a customer name, in this case, for that particular row item, instead of having 61 columns of data I have 62 columns of data
6. export the EXCEL file to an access database

I am able to do all of the above, however my issue is that the text file I am working with is huge, ~130,000 lines of data and so the above VBA macro takes 8 minutes or so to complete. The biggest chunk of time is spent on exporting data to ACCESS.

Currently I export to ACCESS row by row and field by field using the ADODB.Connection and ADODB.Recordset method, i.e.
1a. open a connection to the database
2a. open the table
3a. for each row in the EXCEL spreadsheet add 61 data fields to a new record in the database table

My question (finally ;) !!!) is whether or not there is a faster method to transfer data from EXCEL to ACCESS, i.e. using the transfer.spreadsheet ACCESS function? Some of you will probably point out that it would be faster to just import the data into ACCESS directly from the original text file, but then how would I complete steps 2-5 above?

Thanks for your help and time with this folks.

Cheers,
Derek
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi and welcome to the board!

Have you considered running the code in Access and reading the text file directly into a table, bypassing the Excel step completely? You can do all the data manipulation as you go in the VBA.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,681
Members
452,937
Latest member
Bhg1984

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