New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

correcting dbf file in excel

Macros, VBA, Excel Automation, etc.

correcting dbf file in excel

Postby MichaelQuam » Mon Jan 23, 2012 11:29 pm

Hello, I have several (hundreds) of dbf database files which have a field which needs to be removed from each record in the file. The field is the FIRST field in the record.

There are something like 20 fields, and usually less than 100 records in each database.

Is there any way for a macro to import a dbf file, remove the first field, then save the file to a new file, minus the errant field? I could open each dbf file in excel, delete column A, save the worksheet as a csv and go on to the next file, however like I said I have hundreds of files that I need to do this to.

I can provide a sample of the dbf files if necessary.

Thanks,
Michael Quam
  • 0

MichaelQuam
Rookie
 
Posts: 1
Joined: Jan 23, 2012
Reputation: 0

Re: correcting dbf file in excel

Postby Sisyphus » Tue Jan 24, 2012 2:21 am

Hi,
You can loop through a directory, open each file in turn, do whatever you want with it and save it back.
In Excel 2003 you could save it back in DBF format (2, 3 and 4) but Excel was deprived of that capability in 2007 though I read that there is a work-around:
http://www.dbforums.com/microsoft-excel/1644233-excel-2007-add-save-dbf.html

If you have Excel 2003 or have access to Excel 2003 or have installed the above remedy the task should be like opening each file in Excel, delete column A and save it back in its original format. Else, the format might be CSV and you would need another procedure to convert that back into DBF.

Why are you turning to Excel to do that? Wouldn't Access be more suitable? Or whatever is the native language of DBF files - Dbase, I suppose?
  • 0

Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 151 guests