Tutorial on Excel Macros (VBA)      




















Back to VBA lesson 18

The Excel Database Functionalities

We are surrounded with  databases. All accounting programs, sales programs, inventory programs and other business programs include a database. There is the main database in your corporation, there are databases on the WEB  and all kinds of other departmental databases.

You can bring data from all these databases into Excel to analyse the data and create automated reports. You can also develop very useful databases with Excel. As a matter of fact if people  knew Excel better Access would not exist.

With Excel you can develop analyses and reports that would be impossible or unaffordable to develop even with very sophisticated database programs like PeopleSoft, JDE, Oracle and others. Corporations that can afford these million dollars systems rely often on Excel to analyse the data and design reports to support very important decision making processes. Some of the most powerful analysis tools in Excel are database functionalities like sorting, filtering, subtotals and pivot tables. There is even a form to enter data into an Excel database. It is there as soon as Excel recognizes your set of data as a database.  


Excel needs to recognize your set of data as a database or you will not have access to any of the database functionalities from the "Data" menu item (the basic Sort and Filter or the more advanced Form, Subtotals and Pivot Table).

The DATABASE is a set of columns (called fields by the database people) that include a SINGLE title cell in each column. Select a different format for the title cells as oppose to the other cells of the table so that Excel understands that it is working with a DATABASE. I use bold font in the title cells and I add a border at the bottom of the cells. Use " Text Wrap" in " Format/Cells/Alignment" to write more than one line of text in one cell and use " Alt/Enter" to force a line break within the lines.

The database MUST be surrounded by empty rows (top and bottom) and empty columns (right and left). If you database starts in cell A1, no need to add an empty row at the top or an empty column on the left.

The Excel database goes from the row of title cells to the last row (called record by the database people) that carries at least one value in any of the fields.

If you want to make sure that your database is recognized by Excel, click anywhere in it and go to Edit/Go to/Specials/Current Region. What is then selected is your database.

Here are 4 examples of set of data not recognized as a database by Excel and one real database.

This is not a database recognized by Excel because there are two rows of title cells

Excel Database 1

This is not a database recognized by Excel because row 2 is not empty.

Excel Database 2

This is not a database because columns B, D, F and H are empty. Remove the empty columns and you have a single database recognized by Excel.

Excel Database 3

Here is a  database recognized by Excel. There are 5 fields (columns) (Date, Name, Product, Quantity, Amount) and 7 records (rows of data).  Column E is not empty, the title cell is there and row 4 is not empty there is a data in field 1. There can be many empty cells in an Excel database (except for title cells) but never any empty rows or columns.

Excel database 4

Once you set of data is recognized as a database you can sort and filter data, you can use the form to enter new data and you can calculate subtotals and develop pivot tables.

Back to VBA lesson 18