Style...

Home Search Site Map

Up
AutoFormat...
Cells...
Column
Conditional Formatting...
Row
Sheet
Style...

New! Excel User Group Now Open @ www.excelusergroup.org, Check It Out!


Menu command Type What happens next?
Style... ... Presents the style dialog (below).

A much underused feature of Excel which can save you huge troubles with large spreadsheets.

Excel has a finite limit on the number of different formats that can be used in a workbook and counts a 'format' as any small change in text size, colour, weight, alignment, etc. In a random formatted spreadsheet it is quite easy to hit this limit.  Using styles will add much uniformity to your models and avoid this, as each use of, for example the 'Normal' style counts as one format no matter how many times you use it.

'Normal' is the default for Excel, so if you want to always have say Tahoma as your default font, you would select 'Normal' from the dropdown, click 'Modify...' and select Tahoma from the font list and clicking 'Add'. By de-selecting the checkboxes, shown above, you can exclude complete elements from the style, e.g.. Borders, Pattern, Font, etc. (If you exclude these the settings for the 'Normal' style will be used for those elements not set. For example the 'Currency' style simply sets a formatting string and relies upon the 'Normal' style to provide all the font settings, etc.

You will find all the standard toolbar formatting styles in the dropdown, such as percent and currency, so these can be changed to how you would like to see them displayed.

To add a new style, select the cell(s) with the formatting you want for the new style. Invoke this menu choice, type a name in the 'style name' dropdown and select 'Add' or 'OK'.

Once you have custom styles set up, these can be merged to another workbook by selecting the 'Merge' option in the destination workbook (both source and destination must be open). Excel will ask once if you wish to overwrite styles with the same name if they exist in the other workbook. (As below).

All bar the 'Normal' Style can be deleted although if you delete the currency, comma or percent styles the buttons will not work on the toolbar.

VBA Sub AddApplyAndMergeStyle()
Dim myStyle As Style
Dim myRange As Range
Dim currWb As Workbook
Dim newWb As Workbook
Set myRange = Range("A1")
Set currWb = ActiveWorkbook
'Adds a style called Nick's Style
Set myStyle = currWb.Styles.Add("Nick's Style")
'Sets Nick's Style with a font of Tahoma and Red colour
With myStyle
.Font.Name = "Tahoma"
.Font.Color = RGB(255, 0, 0)
End With
'Applies Nick's Style on myRange ("A1")
myRange.Style = myStyle.Name
'Adds a workbook and merges styles to it.
Set newWb = Workbooks.Add
newWb.Styles.Merge (currWb.Name)
'you will get the 'want to merge' dialog here
'this could be stopped by Application.DisplayAlerts=False
End Sub

Top

Copyright Nick Hodge 2008. All Rights Reserved.