DEFINE.STYLE macro

Equivalent to clicking the Define button in the Style dialog box, which appears when you click the Style command on the Format menu. Creates and changes cell styles. There are seven syntax forms of this function. Use syntax 1 of DEFINE.STYLE to define styles based on the format of the active cell. To create a style by specifying number, font, and other formats, use syntaxes 2 through 7 of DEFINE.STYLE.

Syntax 1

Syntaxes 2-7

Return to index

DEFINE.STYLE Syntax 1

Equivalent to clicking the Define button in the Style dialog box, which appears when you click the Style command on the Format menu. Creates and changes cell styles. There are seven syntax forms of this function. Use syntax 1 of DEFINE.STYLE to define styles based on the format of the active cell. To create a style by specifying number, font, and other formats, use syntaxes 2 through 7 of DEFINE.STYLE.

Syntax

DEFINE.STYLE(style_text, number, font, alignment, border, pattern, protection)

DEFINE.STYLE?(style_text, number, font, alignment, border, pattern, protection)

Style_text    is the name, as text, that you want to assign to the style.

The following arguments are logical values corresponding to check boxes in the Style dialog box. If an argument is TRUE, Microsoft Excel selects the check box and uses the corresponding format of the active cell in the style; if FALSE, Microsoft Excel clears the check box and omits formatting descriptions for that attribute. If style_text is omitted and all selected cells have identical formatting, the default is TRUE; if cells have different formatting, the default is FALSE.

Number    corresponds to the Number check box.

Font    corresponds to the Font check box.

Alignment    corresponds to the Alignment check box.

Border    corresponds to the Border check box.

Pattern    corresponds to the Pattern check box.

Protection    corresponds to the Protection check box.

Related Functions

DEFINE.STYLE Syntaxes 2-7

APPLY.STYLE   Applies a style to the selection

DELETE.STYLE   Deletes a cell style

MERGE.STYLES   Imports styles from another workbook into the active workbook

Return to index

DEFINE.STYLE Syntaxes 2 - 7

Equivalent to clicking the Define button in the Style dialog box, which appears when you click the Style command on the Format menu. Creates and changes cell styles. Use one of the following syntax forms of DEFINE.STYLE to select cell formats for a new style or to alter the formats of an existing style. Use syntax 1 of DEFINE.STYLE to define styles based on the format of the active cell.

Syntax 2

Number format, using the arguments from the FORMAT.NUMBER function

DEFINE.STYLE(style_text, attribute_num, format_text)

Syntax 3

Font format, using the arguments from the FORMAT.FONT and FONT.PROPERTIES functions

DEFINE.STYLE(style_text, attribute_num, name_text, size_num, bold, italic, underline, strike, color, outline, shadow, superscript, subscript)

Syntax 4

Alignment, using the arguments from the ALIGNMENT function

DEFINE.STYLE(style_text, attribute_num, horiz_align, wrap, vert_align, orientation)

Syntax 5

Border, using the arguments from the BORDER function

DEFINE.STYLE(style_text, attribute_num, left, right, top, bottom, left_color, right_color, top_color, bottom_color)

Syntax 6

Pattern, using the arguments from the cell form of the PATTERNS function

DEFINE.STYLE(style_text, attribute_num, apattern, afore, aback)

Syntax 7

Cell protection, using the arguments from the CELL.PROTECTION function

DEFINE.STYLE(style_text, attribute_num, locked, hidden)

Style_text    is the name, as text, that you want to assign to the style.

Attribute_num    is a number from 2 to 7 that specifies which attribute of the style, such as its font, alignment, or number format, you want to designate with this function.

Attribute_num Specifies
2 Number format
3 Font format
4 Alignment
5 Border
6 Pattern
7 Cell protection

Remarks

 

Related Functions

DEFINE.STYLE Syntax 1

ALIGNMENT   Aligns or wraps text in cells

APPLY.STYLE   Applies a style to the selection

BORDER   Adds a border to the selected cell or object

CELL.PROTECTION   Allows you to control cell protection and display

DELETE.STYLE   Deletes a cell style

FONT.PROPERTIES   Applies a font to the selection

FORMAT.NUMBER   Formats numbers, dates, and times in the selected cells

MERGE.STYLES   Imports styles from another workbook into the active workbook

PATTERNS   Changes the appearance of the selected object

Return to index