import csv file into access without some rows

marianne27

New Member
Joined
Jul 1, 2012
Messages
3
Hi,
i need procedure in VBA to import data into access from csv excel file without some records,, as header and footer. Example,,, i have table in csv file, which contains some
sentence which not belong table date
_______________________________________
A1 this is some sentence title.......
A2 title
A3.......
A7 DATA DATA DATA DATA DATA
A8 DATA DATA DATA DATA DATA
......
....
A2210 DATA DATA DATA DATA
A2211 this is some sentence
A2212
_______________________________________________

My Acess shoud contain only record between A7 to A2210. Does anyone knows procedure or whatever in VBA who solves my problems ?

thanks a lot
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Marianne,
You could import the whole thing, then delete the first 6 records. If you don't want the data to be finalized in the database with those 6 records included, wrap the process inside a transaction.

Or, you could also export the Excel file without the first 6 rows as part of the data.
Or, you could identify the first 7 records based on what type of data they contain using SQL to reference the CSV file, and include WHERE conditions that exclude those first 6 records.
Or, you could add a column in Excel with a special value for those first 6 rows, and have a condition in your query to exclude based on that flag.

Or -- probably slowest but likely bareable in this case -- you could open a recordset based on the CSV file, advance to the 7th record, then import the data one record at time in a loop.

You might get more detailed info on an Access forum/group.

Asa
 
Upvote 0
This is not help me.I want procedure, because i have a lot files csv, and i need procedure to do automaticaly that process for me.Not always first 7 rows i need delete.. and some in the end of file senteces.We need procedure that recognize in column 1 numerical data, and if A not numerical data , that rows must be deleted.I several times get csv file, and i must open in access, because other datebases.

Thanky for attemp to help me
 
Upvote 0
Hi Marianne,
I had no indication from your original question that you were looking to identify numerical data in the first column.
Since Ihave not done the task lately, it would take me some time to look up the correct VBA syntax. If you are looking for ONE routine to handle any CSV data going into ANY table, it is very complicated.

If the CSV files always have the same columns and are are always going into the same table, you can use an action query with the following condition on the first field:

IsNumeric([Field1])


I hope my small nudges help you along your way to a solution, in any case.

Asa
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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