Link to home
Start Free TrialLog in
Avatar of Buck Beasom
Buck BeasomFlag for United States of America

asked on

Automating Excel Text File Import from VBA

I have been getting a bunch of data files in .csv format and using Excel to eliminate bad rows and scrub bad cells prior to import. Now I am getting them as .txt files and when I use Excel to open them I lose leading zeroes that I need.

I'm trying to adapt this code from an Excel macro into VBA in Access, but I'm using late binding and Access is blowing up on the code.

Any suggestions on how to "import" in Excel using VBA code would be appreciated.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In Access you can link csv file and create queries for correct import. You will need very small VBA part:
1. Rename (copy) file according to your linked file name (constant)
2. Run import queries
3.  Delete imported csv file
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Buck Beasom

ASKER

The 2 suggestions combined to provide a good solution.

Thank you.