Excel - SQL
Retrieve Data From A Database To Excel Using SQL
Submitted by Ken Puls on Tue, 2006-04-11 23:00. Excel - ADO | Excel - SQL | Excel - VBA | Access - ADO | Access - SQL | Access - VBAMacro Purpose:
- Retrieve a recordset from a database and place it in an Excel worksheet, using an ADO connection to pass SQL strings.
Examples of where this function shines:
- Works well for retrieving data from Access (or other database management system) to Excel.
- Allows working with data in Excel, and making use of its rich features.
- Code is robust enough to support varying amounts of columns or rows in the recordset.
- You can supply your own SQL, allowing you to pull back only the data you need or want to work with.
Populate Multi-Column Listbox With Data From Access
Submitted by Ken Puls on Thu, 2006-02-16 00:00. Excel - ADO | Excel - SQL | Excel - VBA | Access - ADO | Access - SQL | Access - VBAMacro Purpose:
- Retrieves data from an Access database, and fills it into a userform listbox.
Examples of where this function shines:
- The Access database is in an Access 2000 format, but the code can be run from Excel 97-2003 with no issues.
Macro Weakness(es):
- Does not populate listbox with column header names.
- There is no error handling in this routine.
Versions Tested:
This function has been tested with Access & Excel 97, and Access & Excel 2003, and should also work with Access and Excel 2000 and 2002 (XP) without any modifications
Export A Range Of Excel Data To A Database
Submitted by Ken Puls on Mon, 2004-12-20 00:00. Excel - ADO | Excel - SQL | Excel - VBA | Access - ADO | Access - SQL | Access - VBAMacro Purpose:
- Exports a table of data from Excel into a database, using an ADO connection to pass SQL strings.
Examples of where this function shines:
- Works well for archiving data from Excel to an Access database.
- Does not insert rows if all cells in the row are blank (avoids entering completely Null records in the database).
- Code is robust enough to support varying amounts of columns or rows.
- The entire database table structure does not have to be reproduced in Excel, providing that the Database Management System (DBMS) has default values, or can accept NULL values, for any omitted fields.


