Link to home
Start Free TrialLog in
Avatar of salvatore imparato
salvatore imparatoFlag for Italy

asked on

import DBF into excel sheet...

This file contain a wbook and a dbf file.

www.gssitaly.com/pagati.zip

My problem is to import the records from DBF into excel sheet.
Naturally not is very simple.
In effect the the record into dbf file not have the same sequence of the sheet...
The final result is in the wbook.
Tks for all.
note: all in VBA for excel
Avatar of MalicUK
MalicUK

Sorry, I don't know what the problem is. The sheet looks like the data has imported ok.
Avatar of salvatore imparato

ASKER

If you see...
This is an operation for every work day.
Not the first field is in the same position of the sheet, the second....ecc
And i would want all process with a mcro in VBA for excel.
ASKER CERTIFIED SOLUTION
Avatar of ture
ture

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 DrewK
Another option would be to use the database query wizard in Excel to make a connect to your dBase file.

1) Go to "Data-->Get External Data...-->Create New Query
2) Select "New Datasource"
3) Name it something (ex: Pagati)
4) Select "Microsoft dBase driver (*.dbf)"
5) Click "Connect" button
6) Click "OK" button to close the next window that appears ("ODBC dBASE Setup")
7) Click "Connect" button again
8) Click "Select Directory" and browse for you Pagati.dbf file
9) Click "OK" button to close window
10) Click "OK" button to close "ODBC dBASE Setup" window
11) Choose your Pagati table from the drop-down that says "Select a default table for your datasource"
12) Click "OK" button
13) Click "OK" button and the "Query Wizard" should come up and show you all of the fields in your pagati.dbf table
14) Choose each field *IN THE ORDER* that you want it to show in Excel.
15) Click the "Next" button and finish the wizard out.  The last step will give you a "Finish" button which will then produce your spreadsheet the way you want it.

The nice thing about the database query is that you can right-click on cell A1 and select "Refresh" and it will communicate with your .dbf file to get the latest information.

Then you can copy and paste this data into a new workbook and save under a different name?

DrewK
The way to do it in VBA is to create an ADO connection to the dbf file (I believe this is a FoxPro file so you may need to use this http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForVisualFoxPro)

You can then retrieve a recordset and arrange the columns in any order you want with your SQL query.

Leon