Cell Formatting With Font |
|
A font is an art effect made of designed symbols used to represent letters and other characters on a cell or a group of cells. A font is characterized by various characteristics such as a name, a style and a size. |
Microsoft Excel uses some default fonts to display the names of columns and rows on a worksheet. Another font is used by default to show the contents of cells. If you want to use a different font to display text in cells, you can changes these defaults. When changing the default font, in other words if you decide to change the default font, you should use only the most popular fonts that are more likely to be found on your user’s computers. To assist you with setting the fonts of columns, the Ribbon is equipped with a Font section in the Home tab: |
You can make a worksheet user-friendly by applying some fonts and colors to their content. A font is primarily known by its name. When starting a worksheet, Microsoft Office Excel 2007 applies a default font named Calibri to the cells. If you want, you can change it. To visually change the font used by a cell or a group of cells:
To programmatically specify the name of a font, refer to the cell or the group of cells on which you want to apply the font, access its Font object, followed by its Name property. Then assign the name of the font to the cell or group of cells.
Besides its name, a font is also known for its size. The size defines how much height and proportional width would be used to represent the characters of the selected font. To visually specify the font size used by a cell or a group of cells:
When a font is installed, a set of font sizes is created in the Font Size combo box. You can use those numbers but you can also set a new one. To do this, instead of selecting a value in the Font Size combo box, type the desired number and press Enter or Tab. The operating system would calculate the size and apply it. To programmatically specify the font size of a cell or a group of cells, refer to that cell or the group of cells, access its Font object, followed by its Size property, and assign the desired value to it.
Another aspect of the appearance of a font is its style, which is a technique of drawing the characters of the text, depending on the font. This characteristic comes in four options:
To visually change the font style of a cell or a group of cells:
You can specify more than one style on a cell or a group of cells. To do this, click the button of the desired style. When a style is valid for a control, when you click that control, the style button is highlighted: , , or . To remove a style, click the undesired button. To add a style to another style, simply click the desired button. Based on this, you can have one, two or three buttons highlighted in the combination of your choice. To support font styles, the Font object is equipped with various Boolean properties that are Bold, Italic, Underline, and Strikethrough. Therefore, to grammatically specify the font style of a cell or a group of cells, access the cell or the group of cells, access its Font object, followed by the desired style, and assign the desired Boolean value.
|
|
The text in a cell can be improved with color. By default, new text entered in a cell is black. If you want, you can change it. To visually change the color of text in a cell or the color of text in a group of cells, select the cell or the group of cells. In the Font section of the Home tab of the Ribbon, click the arrow of the Font Color button to display the list of colors and select one: If none of the pre-selected colors suits you, click More Colors... then select or create a color using the Colors dialog box. The VBA supports colors at different levels. To support colors, the Font object is equipped with a property named Color. To specify the color, assign the desired color to the property. The VBA provides a (limited) list of colors that each can be specified using a named constant. They are:
Therefore, the available colors are vbBlack, vbRed, vbGreen, vbYellow, vbBlue, vbMagenta, vbCyan, and vbWhite. These are standard colors. In reality, a color in Microsoft Windows is represented as a value between 0 and 16,581,375 (in the next lesson, we will know where that number comes from). This means that you can assign a positive number to the Font.Color property and use the equivalent color. The colors in the Font Color button are represented by a property named ThemeColor. Each one of the colors in the Theme Colors section has an equivalent name in the VBA. If you know the name of the color, assign it to the ThemeColor property. As another alternative to specify a color, in the next lesson, we will see that you can use a function named RGB to specify a color.
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||
Previous | Copyright © 2008-2016, FunctionX, Inc. | Next |
|