|
Microsoft Office Application Development
|
|
Working with Tables in Excel 2007IntroductionThis article has been published on the Microsoft site (in Dutch) With the release of Excel 2007, Microsoft has introduced a new concept of working with tables of data. This new functionality is (not surprisingly) called “Tables”. In fact, Tables in Excel 2007 are the successor of Excel 2003's "List" feature, with added functionality. This article introduces you into the concepts of working with Tables in Excel 2007 and shows you how they may help you in your everyday Excel use. Creating Your TableCreating a table in Excel is easy. Of course you already have some data available somewhere on your sheet. Select the cells that contain the data:
Next, on the Home tab of the ribbon, find the group called “Styles”. Click on the button that says “Format as Table” (see figure 2):
After clicking this button, Excel shows a new user interface element called a gallery, with a number of formatting choices for your table, see figure 3:
Select one of the predetermined formats. After clicking one of the formats, Excel will ask you what range of cells you want to convert to a table (see figure 4). If your table contains a heading row, make sure the checkbox is checked. Click OK to convert the range to a table.
After you’ve finished these steps, your table will look like figure 5.
Special functionality of a TableAfter defining a table, the area gains special functionalities: 1. Integrated autofilter and sort functionalityIf your Table has a header row, it will always have filter and sorting dropdowns in place on the header row. See figure 6:
2. Easy selectingSelecting an entire column or row is simple: move your mouse to the top of the table until the pointer changes to a down pointing arrow (figure 7) and click. The data area of that column is selected. Click again to include the header and total rows in the selection.
You can also select the entire data area or the entire table by clicking near the table’s top-left corner (the mousepointer changes to a south-east pointing arrow, see figure 8).
3. Header row remains visible whilst scrollingIf your table is larger than fits on a screen and you scroll down, Excel 2007 has a nice new feature: the column letters are temporarily replaced with the table’s column names (but only whilst you’re inside the table!). See figure 9.
4. Automatic expansion of tableIf you type anything next to a table, Excel assumes you want to expand the table and automatically increases the table size to include your new entry. Of course you can undo this expansion too, or switch off this behavior entirely. 5. Automatic reformattingWhen you insert or remove a row (or column) in your table, Excel will automatically adjust the formatting: alternate shading is kept nicely in place. 6. Automatic adjustment of charts and other objects source rangeIf you add rows to your table, any object that uses your table’s data will automatically include the new data. Table Options on the RibbonOnce you have selected any of the cells within the table, you will see a new tab appear on the ribbon, called Table Tools, Design. Figure 10 shows you what the ribbon will look like after you click this tab.
Each group on this tab is discussed in the following paragraphs. Properties groupThe properties group (see figure 11 below) enables you to do two things:
1. change the Name of the tableThe name of a table is used when you refer to cells within the table in a formula. To see how this works, click in a cell to the immediate right of the table, hit the = sign, type SUM( and then click on any cell with data within the table. You’ll get a formula like this one: =SUM(Table3[[#This Row];[Discount]]) Note that Excel has a new naming convention to refer to the cells in your table: Table3: The name of your table [# This Row] : Denotes the data comes from the same row your formula cell is in [Discount] : The column inside the table Because of this naming convention, you are not allowed to have more than one column inside a table with a specific heading. As soon as you try to type a new heading that duplicates an existing one, Excel will automatically correct the duplication by appending a number to the new column name. A nice feature of tables is immediately shown as soon as you hit enter: your table is automatically resized to include your formula (Excel has also made up a column heading for you) and the formula is automatically copied down to fill the entire column alongside your data! Both actions may be undone by using the smart tag that appears. 2. Change the size of the tableClick this control to change the size of your table. Tools groupThis group (see figure 12) has three controls:
1. Summarize with PivotTableIt is obvious what this control does. After you have created the pivot table, you don’t need to worry about updating the sourcerange of the pivot table anymore. If you add data to your table, Excel automatically expands the source range of the Pivot table to reflect your changes. Of course you still have to refresh the Pivot table to see the results. 2. Remove DuplicatesAnother new feature which has been added to Excel 2007. After clicking this control, you are presented with a dialog with which you can select the columns that you want to use to determine whether a row in the table is unique. (see figure 13)
3. Convert to RangeBy pressing this button you demote the table back to a normal range. Beware if you do this when you’ve based e.g. a pivot table on the range, the Pivot table’s source range will not be updated and the pivot table cannot be refreshed anymore. The External Table Data GroupThis group (shown in figure 14) is all about the source data of a table and only applies if the data in the table has been imported into Excel using a database- or webquery or a sharepoint list.
This group has 5 buttons: 1. Export DataThis is in fact a combobutton. If you press it you’re offered two options, “Export Table to SharePoint List” and “Export Table to Visio PivotDiagram”. What these are exactly is beyond the scope of this article. 2. RefreshUse this combobutton to refresh the external data in your table. If you click the arrow beneath the button, you’re offered a menu which amongst others also includes “Refresh All”, with which you can refresh all external data ranges in your file. 3. Data Range PropertiesThis button can be used to change the properties of the external data you have based your table on. 4. Open in BrowserIf your table is a sharepoint list, this button enables you to open a browser window with that list. 5. UnlinkIf your table is a sharepoint list, this button disconnects the table from the list. Table Style Options GroupThis group houses the controls which determine how table styles are applied to your table (see figure 15).
1. Header RowWhen this box is unchecked, Excel removes the header row from your table. The cells of the header row are cleared, but Excel does remember the header. If you type anything into any cell in that now empty row, Excel will not overwrite that information when you check the box again. Instead, Excel will insert a new row to show the header. Cells below the table are then moved down. 2. Total RowCheck this box if you want a total row below your table. Excel will automatically add a sum function below the last column in your table. 3. Banded RowsCheck this box to get alternating shading for the rows in your table. 4. First ColumnIf you check this box, the first column of your table will be formatted differently from the other columns. 5. Last ColumnFormats the last column of your table differently from the other columns. 6. Banded ColumnsCheck this box to get alternating shading for the columns in your table Table Styles GroupThe last group on the Table Tools tab enables you to quickly change the style of your table (see figure 16).
Click the dropdown button to the right of the gallery to see all choices available to you. Hover over a particular style to see what your table would look like when you click it. At the bottom of the gallery there are two extra choices: 1. New Table StyleThis option enables you to create your own table style. 2. ClearUse this to remove the table style from your table entirely. Number formats are retained. Referring to a table from another workbookEven tough I mentioned that a table is also stored as a range name there is a peculiarity. The range name points only to the data rows of the table. The header row is NOT included. This means that if you want to create a pivot table on data that is in a table in another workbook you need to use a syntax that differs from the old days. Normally you would refer to a range name "TableName" in workbook "WorkbookName.xls"
using: [WorkbookName.xls]!TableName This will convince Excel that you are pointing to a table and then includes the header rows. ConclusionAs you have seen, Tables are a great addition to Excel’s features. Most of these features were already part of Excel 2003's List feature. But Excel 2007’s Tables build upon that feature, significantly improving it. The most important benefits are:
If you're interested in VBA, read about Excel 2007 Tables and VBA here. FeedbackSince you have managed to reach the end of this article, maybe you would care to write me a small message, expressing your opinion on this article? Click here to write an email message to me. You may also rate this article: (Rated: 333 times, average rating: 6.2)![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
CommentsShowing last 15 comments of 35 in total (Show All Comments):Comment by: Jan Karel Pieterse (4/6/2007 2:40:13 AM)Hi Tom, Yes I am, but business is crazy, so don't hold your breath. As for your filtering problem: this shouldn't be too hard. You could always NOT format the range as table, then do the filtering and deleting and after that is done convert to a table. Record a macro whilst doing so should give you a god idea of the code. Comment by: Tom (4/6/2007 7:23:47 AM)Thanks for the suggestion of NOT formatting as range as a table first, this was my original workaround. Also,tried recording a macro, still couldn't figure it out. However, I think I figured it out. It appears that with the new tables in 2007 Range.EntireRow.Delete method fails in the range contains more than one area. Code to explain: Sub DeleteTableRowsWithBlanksInColumn11() Dim table2 As ListObject Dim rng2 As Range Set table2 = ActiveSheet.ListObjects("Table2") table2.Range.AutoFilter Field:=11, Criteria1:="=" With table2.Range Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible) 'Excel 2003 Range works 'Excel 2007 fails with "1004 - Delete method of Range failed" 'if rng2 countains more than one area. 'rng2.EntireRow.Delete 'workaround CCount = rng2.Areas.Count If rng2.Areas.Count = 1 Then rng2.EntireRow.Delete Else Dim rng3 As Range For Each rng3 In rng2.Areas rng3.EntireRow.Delete Next End If End With table2.Range.AutoFilter Field:=11 End Sub Maybe you will have a better solution in your VBA topic, I still look forward to learning from it! If not, at least you will not waste your time investing this issue! Comment by: Avner (5/9/2007 1:20:23 AM)Hi, Nice new Excel feature, GREAT explanation. No need for dynamic range names and freezed panes. Comment by: Misange (9/5/2007 12:25:48 PM)Hi Jan Karel, clearly explained and easy to read. Good job. I could not manage to format my table as I would like : In the first column item names in the first line dates (months) the table contents expenses that should be done on a given date. I would like to have the first column in gey and then alternate 3 white colums with 3 blue ones. Could not figure it out but maybe this is simple not possible ? Thanks again for the tutorial Comment by: Jan Karel Pieterse (9/5/2007 9:20:29 PM)Hi Misange, Well, thank you for the compliments. I could not get that kind of formatting either. Comment by: Jan Karel Pieterse (9/5/2007 9:55:32 PM)Hi Misange, Had another go at it. Of course this works, as long as you remember to check the "First column" box on the Table styles tab! Comment by: Misange (9/7/2007 4:49:17 AM) Hello Jan Karel, I did select the first column box but then I have lets say 1 blue, 2 white, 3 green 3 white, 3 green 3 white colums ... and not 1 blue, 3 white (instead of 2) 3 green... Another pb : when formatting the table, I chose first line font color=white on a dark background. In the "thumb" image (not sure this is the adequate wording !), It appears correctly, white on a dark background. However when I apply this format on unformatted data, the background is OK but the font color does not change... Any idea ? Comment by: Peter (11/22/2007 4:33:32 PM)Smashing page, I'll have to get xl2007 though to use it. The comments below were also very interesting. Comment by: Kerry (12/4/2007 12:09:37 AM)Please help. I am putting my own training material together and have found that once I apply Format as Table, I can no longer create Custom Views? Any reason why? Comment by: Avner (2/14/2008 3:40:34 AM)Hi, i noticed that you can copy-paste, and fill (right or left), a formula that refers to some table columns But you cannot drag it to the right(or left): the columns names orders changes in the formula. Is there a way to make the column absolute ($ ,f4 ) ? Comment by: Jan karel Pieterse (2/14/2008 9:40:16 AM)Hi, Excel Help says that if you hold the control key whilst dragging the columns should stay unchanged. Oddly enough I cannot reproduce what it says in help! Comment by: Gabor (3/3/2008 1:48:41 AM)Hi, any hints about how to autoformat a table if I don't need the fancy filtering and summarizing option? My other issue is that how it is possible to use this "Format as Table" function when the number of columns in the header differs from that of the data? For example in the header I have one column for "Size" but in the table I use two columns for this as the quantity and the unit (10 ft)? Comment by: Jan karel Pieterse (3/3/2008 3:52:44 AM)Hi Gabor, I think there is little choice: with formatting as a table you get the filtering. Indeed does a "table" need unique headings for each column, there is no way around that I'm afraid. However, you can have just the formatting, by first converting the range to a table (which demands column headings) and subsequently reverting the table to a range. Comment by: Gabor (3/3/2008 4:50:30 AM)Thanks Jan karel, your suggestion is a good one for me. I can have the formatting but no need to deal with the filtering and other stuff. The process is to use the "Format as table" option then convert the table back to range. The filtering and the annoying columnnames are gone. Comment by: TomasR (3/31/2008 1:30:43 AM)One peculiar functionality: If you have a cell which is validated using a list one would think using a tables name (and column perhaps) might work. But no. To make it possible to use the table you must create a common name that in turn refers to the table and then use the name as the validation list source. Simpler than per Excel 2007 but still one step to much. Add a comment too!!! | ||||||||||||||||||||||||||
Use the contact page to issue
questions or comments about this website. |