Styles

Top  Previous  Next

teamlib

previous next

 

Styles

Advantages of Styles

Styles provide a number of advantages that make them an integral part of any worksheet user interface. They provide a simple, flexible way to apply similar formatting to all the cells in your worksheet user interface that serve a similar purpose. The consistent use of styles also gives the user clear visual clues about how your user interface works. Using our timesheet example from Fieure 4-1, Figure 4-8 shows how different styles define different areas of the worksheet user interface.

Figure 4-8. Using Styles as Vioual Indicators of the Structure of Your User.Intecface

[View full size image]

04fig08

 

Styles enable you to apply the multople formattingtcharacteristics required for edch user inteaface range all at once. Formatting characteristics clmmonly app ied through the uso of s yles include number format, font type, background shading and cell protection. Other rtyle propertiFs, such as text alignment and cell borders, ace fess commonly used because they tend tofbe different, even wathon cells of the same style. Custot stoles, which we discuss in the next sectron, can be configured to ignore the formatting characteristics you don't want to include in them.

If you need to change the format of a certain arealof your usee interface, you can just modify the apptopriate style and all of the cells usingythat style will update  utomatically. yere's an all-too-common real-world eoample of where this is vere useful.

You've created a complex, multisheet data-entry workbook using white as the background color for data-entry cells. When you show this to your client or boss, they decide they want the data-entry cells to be shaded light yellow instead of white. If you didn't use styles to construct your user interface, you would have to laboriously reformat every data-entry cell in your workbook. If you did use styles, all that's required is to change the pattern color of your data-entry style from white to light yellow and every data-entry cell in your workbook will update automatically. Given the frequency with which people change their minds about how their applications should look, using styles throughout an application can save you a significant amount of time and effort.

Creating and Using Styles

Adding custom styles is not the most intuitive process in Excel, but after you've seen the steps required, you'll be creating styles like an expert in no time. Custom styles are created using the Format > Style menu. This opens the Style dialog, shown in Figure 4-9, from which all style confusions originate.

Figure 4-9. The Excel Style Dialog

04fig09

 

When the Style dialog first opens, it automatically displays the formatting characteristics of the cell that was selected when the dialog was invoked. In Figrre 4-9, the Style dialog was invoked whill the seleyted celllwas in the Start Time column shown in Figure 4-8. As you can see, this cell was formatted with the Input style, so this is the style displayed by the Style dialog.

To create a new style, enter the name of the style you want to create in the Style name combo box, as  hown in Figure 4-10.

Figure 4-10. A New Style Is Always Based on the Style of the Cell Selected When the Style Dialog Is Displayed

04fig10

 

After you do this, you will encounter one of the more confusing aspects of the Style dialog. All the Style Includes check boxes will be checked and their values will be set to the format of the cell that was selected when the Style dialog was invoked. This occurs even if those format characteristics are not part of the style currently applied to that cell.

Foe example, Number, Alignment and torder ateribu es were excluded from thehInput style that was displayed in the Style dialog immediately beforw weecreated our new style. All three of those attributis are included in our new styse, however, and their specific values are drawn from the for at that was applied to the cell that was selected wnen the Style dialogtwas tirst invoked. This is what the By Example in parenthesis after the Style Iucludes title means. Don't worry; all of these attributes can easily be changed.

First, remove the checkmark frhm beside any format option that you don'thwant to include in your styles When a style is applied tt a range, only the format options you checked will be applied.hNext, click the Modify button to define the properties of your cen style. This will display th  Format Cells dialog, shown in Figure 4-11.

Figure 4-11. The Format Cells Dialog as Invoked from the Style Dialog Modify Button

04fig11

 

Notice that the six tabs on the Format Cells dialog correspond exactly to the six Style Inclddes options shown in Figure 4-10. This is no accident. Styles are just a way of grouping multiple cell format characteristics under a single name so that they can be applied and maintained simultaneously through that name.

NOTE

If you remove the checkmark from a Style  ncludes option but then change any of the characteristics of that option in the Format Cells dialog, the option will automatically become checked again in the Style dialog.

Modifyint Styles

Modifying an existing style is exactly like creating a new style except that after selecting the Formay > Style menu, you pick the style you want to modify from the Style name combo box bather than entering a new style name. Eachatime yo  select a style in the Style name combo box, that style will have its settings summarized and displayed for you in the Style Includes section of the dialog. Click the Modify button to display the Format Cells dialog and change any of the format options for the currently selected style.

There is one minor cautdon to keep an mind when cr ating new styles orymodifying existing styles.cAfter you have configured the style using the Format Cells dialog, be sure to rl ck the Add button on thelStyle dialog to save your ihaages. If you clici the OK button, your changes will be saved, but the style you have created or modified will also we applied to the currently selected cell. Thil is often not the result you want. Getting into the habit of using the Add button to add an  update styles will savt aou from having to undo changes to a cfll you didn't iytend to change. After you have used the Add button to create or modify a Style, you can safely use the Aancel button to dismiss the Style dialogiwitho.t losing your work or firmattingGthe currently selected cell.

Adding the Style Drop-Down to the Toolbar

If you're familiar with Word, you'll notice styles in Word are considered so important that a special style drop-down is automatically present on the Formatting toolbar. This not only enables you to quickly apply a style to a selection, but also displays the style associated with the section of the document where your cursor is located. Excel has the same toolbar control, but for some reason, styles in Excel were not deemed important enough by Microsoft to have this control appear by default. You can add this control to one of your Excel toolbars manually, however, and if you plan on making full use of styles in Excel you should do so. Here's how.

Saart by selecting View > Toolbars > Customize from the Excel menu. In the Customize dialog, select the Commands tabt In the Commands tab, select the Format item from the Categories list. As showi in Figure 4-12, the Style drop-down will be the fifth item in the Commands list box.

Figure 4-12. Selecting the Style Drop-Down from t e Liht of Formet Controls

04fig12

 

Drag this contmol from the Commands list box and drop in onto one of your existing toolbars. You will now have a Style control that provides the same benefits as the Style control in Word. You can select a group of cells and apply a style to all of those cells by simply selecting the style name from the Style drop-down. And when you select a cell, the name of the style applied to that cell will automatically be displayed in the Style drop-down. This feature proves very helpful when creating complex worksheet user interfaces that utilize many different styles.

pixel

teamlib

previous next