Article ID: 142122
Article Last Modified on 10/11/2006
A1: 1 B1: 2 C1: 3 D1: 4
Sub Checking_the_Format()
Range("A1:D1").Select
' Use a loop to check each cell in the selection.
For Each cel In Selection
' The next line tests for the bold property of the font.
If cel.Font.Bold = True Then MsgBox "This cell is bold: " _
& cel.Address
' The following line will display the font style of the current
' it is not bold or italic.
If cel.Font.FontStyle <> "bold" Or _
cel.Font.FontStyle <> "italic" Then _
MsgBox cel.Font.FontStyle
' This example will check the underline of the font in the
' current cell to see if it is a single line (xlsingle).
If cel.Font.Underline = xlSingle Then _
MsgBox "Here is the single underline: " _
& cel.Address
' Finish the loop.
Next cel
' The next line sets the weight and color of the left border of
' the current selection.
With Range("B3").Borders(xlLeft)
.Weight = xlMedium
.ColorIndex = 3
End With
Range("A10").Select
End Sub
For this property True means this False means this
-------------------------------------------------------------
Bold Font is bold Font is not bold
Italic Font is italic Font is not italic
OutlineFont Font is outline Font is not outline Font
font
Shadow Font is shadow Font is not shadow Font
font
Strikethrough Font is Font is not formatted with
formatted with strike through
strike through
Subscript Font is Font is not subscript
subscript
Superscript Font is Font is not superscript
superscript
For this property Test for this value
------------------------------------------------------------------
Color The font color as an RGB value
ColorIndex The color as an index number from
the current color palette
FontStyle The font style as a string (for
example, "Bold")
Name The name for the font (for example, "Arial")
Size The size of the font (for example, 12)
Underline The type of underline applied to text in a
the cell (for example, "xlSingle")
For this property Test for this value ----------------------------------------------------------------- Color The border color as an RGB value ColorIndex The color as index of the current color palette Linestyle The line style (for example "xlContinuous") Weight The weight of the line (for example "xlHairline")
For this property Test for this value --------------------------------------------------------------- Color The primary color ColorIndex The color as index of current color palette Pattern The pattern (for example, "xlChecker") PatternColor The pattern color as a RGB value PatternColorIndex The color as index of current color palette
Font Object
-or-
Border Object
-or-
Interior Object
Font Object
-or-
Border Object
-or-
Interior Object
Additional query words: 5.00a 5.00c 8.00 XL97
Keywords: kbdtacode kbhowto kbprogramming kbualink97 KB142122