Article ID: 193563
Article Last Modified on 10/11/2006
A1: 1 B1: 2 C1: 3 D1: 4
Sub Checking_the_Format()
Dim cel as Range
' Use a loop to check cells A1:D1
For Each cel In Range("A1:D1")
' 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
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
Additional query words: XL98
Keywords: kbdtacode kbhowto KB193563